Skip to content

Software Development at Program Tom LTD

Place for coding, programming, development and software in general.

Menu
  • Blog
  • PDF Booklets
  • Dev Utils & Content
  • Java Spring Boot Or Web Apps
  • English
    • български
    • English
    • Español
    • Português
    • हिन्दी
    • Русский
    • Deutsch
    • Français
    • Italiano
    • العربية
  • About Us
Menu
Watermark Flutter Photo Video

How to Add Watermark to Photo – Flutter

Posted on April 16, 2021February 20, 2024 by Toma Velev

In many apps you will need to add Watermark to a Photo or picture and this is possible using Flutter and a plugin that is supported on all platforms. It is the image: https://pub.dev/packages/image package. You could find that – it is written in the GitHub Description – it is coded in dart programming language. The benefit of not depending on native platforms may go down in terms of performance. It may have performance issues especially at edge cases and you should test it and take care of them.

Install

Add the package to your pubspec.yaml:

dependencies:
  image: ^3.0.2

This is – if some other package does not depend on it and you don’t have it.

Import

Next, in your dart source file, you must include it:

import 'package:image/image.dart'; // or
import 'package:image/image.dart' as ui;

Usage

First you need to initialize some image. You could do that from a initial source of all type of formats – PNG, JPG, PSD, ICO, GIF, etc. The source package processes bytes list. You must have read it from network or local source. This is a subject for another article.

Once you have a ui.Image, you have in memory a bitmap, X/Y matrix with pixels that you could manipulate somehow. The Plugin has a lot of methods to do stuff on it:

  • Draw another image into a region (drawImage). This method will resize the image according to the destination size/area.
  • copy another image into the existing one – (copyInto – with a destination x/y, with the specified rectangle)
  • drawString – with specified font, starting at desired x/y position
  • trim, adjust, crop, alpha (transparency), contrast, resize, etc.
  • and final – encode to -> PNG, JPG, ICO, GIG, etc.

Once you are done, you should free the memory – for usage by other tasks in the application. This may be – setting variables to null at the end of what you do, so you as a programmer to do what is in your hands to free the memory of a managed language. One more aspect is, if you will have multiple operations, to try to cache some memory/bytes, and try to reuse them. This is an approach implemented in several Android libraries and in the API itself. It should be tested deeply and carefully.

Watermarking Products

I’ve made a Two equivalents that do the functionality of this article.

  • Watermarker Web Page – Free – Web Page does the logic in pure JavaScript – without sending any information on the server.
  • Vaadin – Spring Boot – Web App Image Watermark Maker - Java Vaadin Web App– Paid – Product that stores the data on the Server. The features are:
    • You could choose from multiple images to watermark
    • Apply the selected watermark to multiple images.
  • Feature Flags – Enable Functionality from the BackEnd
  • Integrating xAI Grok API with Spring Boot
  • How to Progresively Integrate AI
  • What is an AI Agent
  • Flutter image scaling

Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (256)
  • Graphical User Interface (14)
  • Marketing (116)
  • Software Development (281)
  • Spring (44)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (14)

Tags

Algorithms (9) crypto (29) flutterdev (39) General (86) Java (7) QR & Bar Codes (3) Software Dev Choices (33) Spring Boot (1) standards (1) Theme (3) User Authentication & Authorization (9) User Experience (10) Utilities (19) WordPress (11)

Product categories

  • All Technologies (84)
    • Flutter Apps (24)
    • GPT (4)
    • Java (38)
    • Native Android (3)
    • PHP (9)
    • Spring (Boot) / Quarkus (35)
    • Utils (15)
    • Vaadin 24+ (27)
    • Vaadin 8 (1)
  • Apps (18)
    • Employees DB (1)
    • Notes (6)
    • Personal Budget (1)
    • Recipes Book (1)
    • Stuff Organizer (1)
    • To-Do (2)
  • PDF Books (3)
  • Source Code Generators (8)

Recent Posts

  • Feature Flags – Enable Functionality from the BackEnd
  • Integrating xAI Grok API with Spring Boot
  • How to Progresively Integrate AI
  • What is an AI Agent
  • Flutter image scaling

Post Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (256)
  • Graphical User Interface (14)
  • Marketing (116)
  • Software Development (281)
  • Spring (44)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (14)