Page 1 of 1

[SOLVED] HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-11-30T21:53:19-07:00
by msx
Hi!
This is the situation: I have a PNG with transparent background containing a flyleaf at the bottom of the file and I want to impress it over several other image files; the PNG flyleaf file and all the rest of the other files have the same size. I would like to make a script using Bash -or even Perl with the PerlMagick application- to automate this but I'm having a hard time trying to figure out how to do this with 'convert' application so I'm looking for any feedback you can provide!

branding_file.png
book1_picture.jpg
book2_picture.jpg
...
book25_picture.jpg

The idea is to impress branding_file.png over book*_picture.jpg creating book*_picture_stamped.jpg

Thank you =)

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-11-30T22:07:49-07:00
by GreenKoopa
The -composite command will work for combining images.

An entire page of usage examples:
http://www.imagemagick.org/Usage/compose/

This task should be reasonably easy.

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-11-30T22:15:20-07:00
by GreenKoopa
As for your second need, inputting and outputting multiple files, using * or ? works like one would expect.

Usage Examples > Image File Handling
http://www.imagemagick.org/Usage/files/

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-11-30T23:07:30-07:00
by msx
Thanks! I did a search but didn' find nothing, I'll take a look now =)

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-11-30T23:51:23-07:00
by anthony
You can do this overlay with mogrify, though because of its limitation with handling two images simultaneously, you will need to use -draw to do the image overlay.

See http://www.imagemagick.org/Usage/basics ... fy_compose

As the overlay image is only a corner, it should be posible to use a smaller overlay.
If you can provide a link to the images I can try out and demonstrate an actual command, or posibly figure out a better method.

PS: also see Thumbnails, Double Masking Technique,
http://www.imagemagick.org/Usage/thumbn ... ouble_mask
this is also very appropriate to doing curled corners. I just have not added examples of curled corners as yet.

you amy also like to look at Fred Wienhaus's PageCurl script...
http://www.fmwconcepts.com/imagemagick/ ... /index.php

Re: HowTo 'stamp' Image1 on top Image2 on new Image

Posted: 2010-12-02T20:26:30-07:00
by msx
@anthony
I _really_ appreciate this! I own a little but well provided second-hand bookshop and I'm trying to build an online catalogue. If you ever saw "Black Books" (WP: http://en.wikipedia.org/wiki/Black_Books YT:[0]) then you know what I'm talking about =)

This is a sample book cover http://www.fileden.com/files/2010/5/7/2 ... ATURA.jpeg and this is the file I want to stamp over it and the other pictures: http://www.fileden.com/files/2010/5/7/2 ... 0LEEyC.png, in the end I should have something like this: http://www.fileden.com/files/2010/5/7/2 ... IATURA.jpg
I already created a template to do this in GIMP but I really want to make this the most automated way it's possible, also I'm a CLI junkie so I enjoy creating scripts to handle these things.

I must point I'm not scared of RTFM, I'm just short of time these days. Anyway, I was to do that when I found your kind help offer.
Greetings,
Martin

[0]
http://www.youtube.com/watch?v=Kpr-JunXMkM
http://www.youtube.com/watch?v=VQ74p_XS ... re=related
http://www.youtube.com/watch?v=OMXdziu8FBk

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-12-02T21:01:16-07:00
by GreenKoopa
The solution in my head seemingly differs from Anthony's, but here is my try:

convert book*_picture.jpg null: branding_file.png -layers composite book%%d_picture_stamped.jpg

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-12-02T23:27:03-07:00
by msx
@GreenKoopa
HAHA, that was BRILLIANT! Thank you very much for that, sure I owe you guys some cold beers! :D:D:D
Now I can finish my script to automate batch process: rotate, resize and thumbnail creation of books covers.

I'm a Free Software advocate and FLOSS supporter and in line with my way I will donate to ImageMagic once the eshop is rolling. I strongly believe one should support freely available, useful and excellent software as ImageMagic is, in this case backed by a great community.

Once again, thank you *very* much.
Best,
Martin

Re: [SOLVED] HowTo 'stamp' Image1 on top Image2 on new Image

Posted: 2010-12-02T23:37:12-07:00
by GreenKoopa
I'm only a new user myself, but I'm sure they would appreciate your support. They certainly deserve some.

I didn't test my proposed solution so please let us know if it somehow doesn't meet your needs. I have done much combining of images, but I only work with one at a time and so have never tried the same operation across a collection of images like you need.

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2010-12-02T23:48:48-07:00
by anthony
GreenKoopa wrote:The solution in my head seemingly differs from Anthony's, but here is my try:

convert book*_picture.jpg null: branding_file.png -layers composite book%%d_picture_stamped.jpg
Slight variation that will handle any image name, and just prefix 'stamped_' to the result
That can also be a path to a different directory!

Code: Select all

convert book*_picture.jpg -set filename:original %f \
            null: branding_file.png -layers composite \
            +adjoin stamped_%[filename:original]
See IM Examples, Filename Percent Escapes
http://www.imagemagick.org/Usage/files/#save_escapes
I was amazed it works so well!

Re: HowTo 'stamp' Image1 on top Image2 on new Image3

Posted: 2011-03-20T22:32:23-07:00
by anthony
anthony wrote:
GreenKoopa wrote:The solution in my head seemingly differs from Anthony's, but here is my try:

convert book*_picture.jpg null: branding_file.png -layers composite book%%d_picture_stamped.jpg
Slight variation that will handle any image name, and just prefix 'stamped_' to the result
That can also be a path to a different directory!

Code: Select all

convert book*_picture.jpg -set filename:original %f \
            null: branding_file.png -layers composite \
            +adjoin stamped_%[filename:original]
See IM Examples, Filename Percent Escapes
http://www.imagemagick.org/Usage/files/#save_escapes
I was amazed it works so well!
One word of warning about using convert. It reads ALL the images into memory first.
If the images are large, then you may run out of memory.

Using mogrify will only read one filename at a time, and thus uses far less memory.
However as mentioned you are limited to using -draw to do the image composition
http://www.imagemagick.org/Usage/basics ... fy_compose
Basically as "mogrify" is limited to using "Simple Image Processing Operators"
http://www.imagemagick.org/Usage/basics/#option_simple
That excludes multi-image sequence operators such as -composite, and -layers