[solved] bulk watermarking images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Gruenbaum
Posts: 3
Joined: 2019-09-20T11:30:48-07:00
Authentication code: 1152

[solved] bulk watermarking images

Post by Gruenbaum »

hi all.

i got 2 issues when trying to watermark images.
here is the command i use (im unsing windows cmd):

Code: Select all

magick composite -tile watermark.png *.png watermarkresults_%d.png
so basically i want to watermark all images ( *.png) in a folder using the watermark.png as a sample watermark. the result output shall be written for each image in the folder in this pattern: watermarkresults_%d.png
when i do that, i only get 1 output image and its covered with a tile of one of the images in the folder, having the same resoltuion as the watermark image. so basically doing as said in my command, doesnt use the watermark.png, doesnt watermark all images, but it only does take one image and make it full tiled (-tile) with a part of one of the images, cropping out the same size as the water mark, and filling that one output files with it.

watermarking only worked with a singple image, for example:

Code: Select all

magick composite -tile watermark.png example_original.png water_exampleoriginal.png
and additionally i would like to change the -tile command pattern. usually the complete image is filled by the watermark, but i would like to have some distance between the fillings so the watermark will be put on the image only a few times and not 1000 times until the original image is full.

any advices?
Last edited by Gruenbaum on 2019-09-20T13:16:50-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: bulk watermarking images

Post by fmw42 »

magick composite is a very old method. You are better off using just magick (the ImageMagick 7 equivalent of convert for ImageMagick 6). However to watermark a whole folder of images with the same watermark image, you should use magick mogrify. See alpha compositing with mogrify.

https://imagemagick.org/Usage/basics/#mogrify
https://imagemagick.org/Usage/basics/#mogrify_compose

If each image needs a different watermark image, then you will have to write a script loop using magick. That will depend upon your platform/OS.
Gruenbaum
Posts: 3
Joined: 2019-09-20T11:30:48-07:00
Authentication code: 1152

Re: bulk watermarking images

Post by Gruenbaum »

thanks for your answer. i tried to use mogrify but it kind of confused me. i will show what i did:

Code: Select all

magick mogrify *.png -tile -draw "image srcover 0,0 0,0 'water.png'" output_%d.png
tbh i dont know what command i should use. i just read the manual and put someting together. but yeah it doesnt work. it outputs broken images for me, no watermark added and the names are not changed into output_%d.
even if i do this code without ' -tile ' it isnt working. without - tile it would be like this for me:

Code: Select all

magick mogrify *.png -draw "image srcover 100,100 0,0 'water.png'" output_%d.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: bulk watermarking images

Post by snibgo »

"mogrify" doesn't take an input filename and an output filename. It takes only one filename.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: bulk watermarking images

Post by fmw42 »

try

create a new directory to hold the results -- the input names will be used for the output

change directory to the directory holding the input

move the watermark to another directory

Code: Select all

magick mogrify  -path path_to/new_directory -draw "image over 0,0 0,0 'path_to/water.png'" *.png
supply your actual path to the output directory and the path to the water.png image.

I am not sure you can use -tile in magick mogrify or even in magick. So you may need to tile out the water.png image as desired first and then use magick or magick composite in a script loop for each image you want to watermark.

See

https://imagemagick.org/Usage/compose/#compose
https://imagemagick.org/Usage/layers/#composite
https://imagemagick.org/Usage/layers/#convert
https://imagemagick.org/Usage/canvas/#tile

If you post links to your input and water.png images, we can show you examples.
Gruenbaum
Posts: 3
Joined: 2019-09-20T11:30:48-07:00
Authentication code: 1152

Re: bulk watermarking images

Post by Gruenbaum »

i didnt know mogrify didnt need input and output files. thanks for that tip. now it worked perfectly and with the -path advice (seperating output path and the path where my watermark image is) i could seperate the output files without any problem.

EDIT: nevermind i jsut saw you already told me that i need to tile out my watermark image first and then use mogrify or composite in a batch script.

- thanks for all the help guys and gals!
Post Reply