ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Add barnding watermark on pictures in a folder

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
esprd Posted - Nov 12 2025 : 03:05:27
Hi,

I need to create a tool which will add branding of all JPG present in a folder (picture or text).

I know how to do it, but I find it quite long (~ 3 s / picture, 1 min for 19 pictures), knowing that I have hundreds of pictures to process.

Below is my code, using layers. I already fill the branding layer once. But what costs is the load of the background (6960x4640) and the LayersSaveMergedTo process


procedure TForm4.btnWatermarkProcessClick(Sender: TObject);
var
  MyImageEn : TImageEnView ;
  FolderName, NewFolderName, PictName : string ;
  FileList : TStringDynArray ;
  i : integer ;
  Cnt1, Cnt2 : integer ;

begin
  //---- For all "_VIS.JPG" files in background image folder, add a watermark and save to _Watermarked sub folder
  // Get folder name
  FolderName := ExtractFilePath( OpenPictureDialog1.FileName ) ;

  // Create _Watermarked sub folder
  NewFolderName := FolderName + '_Watermarked\' ;
  if not DirectoryExists( NewFolderName ) then
    ForceDirectories( NewFolderName ) ;

  // Get FileList
  FileList := TDirectory.GetFiles( FolderName, '*_VIS.JPG' ) ;

  MyImageEn := TImageEnView.Create( nil ) ;
  MyImageEn.IO.LoadFromFile( OpenPictureDialog1.FileName ) ;

  // picture layers
  if MyImageEn.LayersCount <> 2 then
  begin
    MyImageEn.LayersClear( false );
    MyImageEn.LayersAdd(MyImageEn.Layers[0].Kind,
                           MyImageEn.Layers[0].PosX,
                           MyImageEn.Layers[0].PosY,
                           MyImageEn.Layers[0].Width,
                           MyImageEn.Layers[0].Height) ; // Append a new layer
  end ;

  MyImageEn.LayersCurrent := 1 ;
  MyImageEn.IO.LoadFromFile( 'C:\_DEV\MyBranding.png' ) ;

  // Set background as current layer
  MyImageEn.LayersCurrent := 0 ;

  // Process on folder files
  for i := 0 to High( FileList ) do
  begin
    // Load picture as background
    MyImageEn.IO.LoadFromFile( FileList[i] ) ;

    // New pict name
    PictName := StringReplace( FileList[i], FolderName, NewFolderName, [rfReplaceAll] ) ;

    // Save picture
    if FileExists( PictName ) then
      System.SysUtils.DeleteFile( PictName ) ;

    MyImageEn.LayersSaveMergedTo( PictName );
  end;

  MyImageEn.Free() ;

end;



Is there another faster way to do that ? Could I do the same without really loading the pictures ? I've made some tests on web sites dedicated to watermarking and it was much more faster.

Regards



ep
1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Nov 12 2025 : 13:19:14
Hi

I expect most of the slowness will simply be the I/O (loading and saving) of each image, so your first check should be that you are using the best imaging engine. You will find DLL or WIC to be faster than native for JPEG:

http://www.imageen.com/help/TIEGlobalSettings.JPEGEngine.html


Secondly, it's probably not a major factor, but I would try it without using layers.

i.e. Load each image, draw the branding image (ensure you load it only once into a temp TIEBitmap) using:

http://www.imageen.com/help/TIEBitmap.DrawToTIEBitmap.html

Output the text:

http://www.imageen.com/help/TIECanvas.DrawText.html

Then save.


I expect when you are testing a similar process on web sites you are not taking into account the disk loading and saving times.

Nigel
Xequte Software
www.imageen.com