Search packages, repositories and app categories

GitHub repositorysaurabh-m-w/image_watermark

image_watermark

image_watermark flutter pacakge https://pub.dev/packages/image_watermark

image_watermark project cover
Stars
17
Forks
16
Last push (UTC)
Mar 22, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Image Watermark

Languages

Spanish

Image watermark is flutter pacakge to add text watermark and image watermark on image,you can customize the position of watermark and color.

Based on Image pacakge.

Check on pub.dev

Example code

Add watermark text at center of image,parameter image bytes and string and it returns image bytes

final watermarkedImg = 
  await ImageWatermark.addTextWatermark(
    imgBytes: imgBytes,
    watermarktext: 'watermarkText',
  );
final watermarkedImgBytes = 
    await ImageWatermark.addTextWatermark(
            imgBytes: imgBytes, ///image bytes
            watermarktext: 'watermarkText', ///watermark text
            color: Colors.white, ///default : Colors.black
          );

Change the position of watermark

final watermarkedImg = 
    await ImageWatermark.addTextWatermark(
            imgBytes: imgBytes,             ///image bytes
            watermarktext: 'watermarkText',      ///watermark text
            dstX: 20,                   ///position of watermark x coordinate
            dstY: 30,                   ///y coordinate
            color: Colors.green, ///default : Colors.black
          );

Add image as watermark on image

final watermarkedImgBytes = 
    await ImageWatermark.addImageWatermark(
            originalImageBytes: imgBytes,
            waterkmarkImageBytes: watermarkImgByte,
          );
final watermarkedImgBytes = 
    await ImageWatermark.addImageWatermark(
            originalImageBytes: imgBytes,  //image bytes
            waterkmarkImageBytes: imgBytes2, //watermark img bytes
            imgHeight: 200,   //watermark img height
            imgWidth: 200,    //watermark img width
            dstY: 400, //watermark position Y
            dstX: 400, //watermark position X
          );
Add Fonts

Image package only have arial Fonts, you can change the font converting a .ttf font in .fnt format:

  1. Download your font in .ttf format.

  2. Convert the font to .fnt format using the next site.

  3. Use ImageFont class, readOtherFontZip if you use .zip file; readOtherFont if you unzip and get the .fnt & .png files.

Example to change fonts

Add the font in pubspec.yaml:

  assets:
  - path/to/font.zip

Then use it as follows:

final assetFont = await rootBundle.load('path/to/font.zip');

final font = assetFont.buffer.asUint8List(assetFont.offsetInBytes, assetFont.lengthInBytes);

final bitMapFont = ImageFont.readOtherFontZip(font);

...

await ImageWatermark.addTextWatermark(
  imgBytes: imgBytes,
  font: bitMapFont, /// Font from .zip
  watermarkText: 'watermark text',
  dstX: 20,
  dstY: 40,
)

Screenshots

Screenshot

Screenshot

Screenshot

Saurabh Waghmare GitHub avatar
GitHub author

Saurabh Waghmare ↗

Pune,Maharashtra,IndiaOfficial website ↗
LanguagesDartHTMLSwiftKotlinObjective-C

Packages published by this repository

Dependencies used

Dependency list 4 items

  • flutter{"sdk":"flutter"}
  • image^4.1.7
  • flutter_testDevelopment{"sdk":"flutter"}
  • flutter_lintsDevelopment^3.0.1

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗