The best way to add a PNG mask using convert?

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
webunity

The best way to add a PNG mask using convert?

Post by webunity »

Right now i have this working code, to add a transparant image called "mask.png" to a "test.jpg" file:
convert -quality 70 -draw 'image Over 0,0 1024,768 "mask.png"' "test.jpg" jpg:"e4408a4e.jpg"

This command takes about 2 seconds to complete, and i think there must be a quicker way.

All i want to do, is "overlay" the mask onto the input picture. I've had faster results with using this command:
composite -compose plus "mask.png" "test.jpg" jpg:"e4408a4e.jpg"

But i also need to resize the input file, so i thought i'd do it in one call to convert.

Allready found the answer thanx to this page: http://www.imagemagick.org/Usage/thumbnails/
convert "test.jpg" -quality 70 "mask.png" -compose Over -composite jpg:"e4408a4e.jpg"
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: The best way to add a PNG mask using convert?

Post by anthony »

Good to see you using IM Examples.

You can however also resize and position the image in composite (and convert) using the -geometry operator. See
http://www.imagemagick.org/Usage/resize/#geometry
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply