Batch Label / Annotating 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
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Batch Label / Annotating Images

Post by robocop »

I have a directory and several sub-directories below the main directory with thousands of images.

I would like to apply a simple text label to all the images at once.

The Annotating Images / Labeling an Image command works perfectly as I have tested it on a few of my images:
http://www.imagemagick.org/Usage/annotating/#annotating

Code: Select all

convert dragon.gif   -background Khaki  label:'Faerie Dragon' \
          -gravity Center -append    anno_label.jpg
I would just like to know how can I do it all at once in batch since the label will be the same for all images

Any advise would be greatly appreciated.

Thank you in advance
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Label / Annotating Images

Post by fmw42 »

create your label as an transparent background image, then use mogrify to apply it to every image in a given folder. Note it does not do subfolders.

see
http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics ... fy_compose

Otherwise, you need to create a script to loop over every directory and every subdirectory and apply the label. With the above, you have to repeat the mogrify only for each distinct subdirectory.
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: Batch Label / Annotating Images

Post by robocop »

Thanks fmw42 for your advise.

I'll go ahead and make the the label as a transparent background image and use the mogrify command.

Cheers
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch Label / Annotating Images

Post by fmw42 »

robocop wrote:Thanks fmw42 for your advise.

I'll go ahead and make the the label as a transparent background image and use the mogrify command.

Cheers

I recommend that you use the -path option to another empty directory to be sure you do not overwrite your originals with bad processing or errors
Post Reply