Need help with watermarking in Imagemagick

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
tcarp
Posts: 3
Joined: 2014-03-18T07:56:42-07:00
Authentication code: 6789

Need help with watermarking in Imagemagick

Post by tcarp »

Hi everyone,

I am brand new to this forum, so thanks in advance for and help I really appreciate it!

So anyways I have about 1000 images in a folder called "Photos Compressed". The folders are numbers as follows "001, 002, etc." Each folder has 8-10 images in it. These image are 2400w x 1600h in dimension. I have a watermark that I created in Photoshop which I then saved as a PNG that is the same size (2400 x 1600).

I need to add the watermark to all of the photos using ImageMagick. I wanted them to go into a new folder called "Photos Watermarked". These new images need to maintain the folder structure of the old folder "Photos Compressed" with all subfolders etc. These new photos also will be scaled down to 640h x 480w.

I basically want the .png watermark to overlay each new image in the new folder keeping the folder structure.

How would I go about this? I am unfamiliar with ImageMagick and I have access to both a Mac and a PC. I tried using Photoshop's image processor but it takes forever and it is not working properly. Any help would be greatly, greatly appreciated.

Thanks!
Tom
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Need help watermarking images in Image Magick!

Post by snibgo »

Do you know how to write scripts on either machine? Pick the one you are most familiar with.

Perhaps you have the 640x480 dimensions the wrong way round.

I would start by working out the command that works on a single image. It might be something like:

Code: Select all

convert in.tiff watermark.png -composite -resize 640x480 out.tiff
When that does what you want, you could put that in a two nested loops: the outer one loops through directories, the inner one loops through images in the directory. Instead of the inner one, you could use mogrify. (I wouldn't, simply because I rarely do this kind of work, and don't mind the performance penalty of running "convert" on every image.)
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Need help watermarking images in Image Magick!

Post by Bonzo »

Instead of the inner one, you could use mogrify.
I think mogrify reads all the images in before the conversion starts which could result in a memory problem? I suppose you could send the images to mogrify in batch's but I would use convert as well.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Need help watermarking images in Image Magick!

Post by snibgo »

Bonzo wrote:I think mogrify reads all the images in before the conversion starts which could result in a memory problem?
Could be. If there are only 10 images per directory, at 8 bytes/pixel, this is 307MB, which probably isn't a problem.
snibgo's IM pages: im.snibgo.com
tcarp
Posts: 3
Joined: 2014-03-18T07:56:42-07:00
Authentication code: 6789

Re: Need help watermarking images in Image Magick!

Post by tcarp »

thanks guys! I am more familiar with Windows command line. I used FFmpeg before to convert videos.
Post Reply