Page 1 of 1

Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-03T17:53:44-07:00
by Jezza
Hello ImageMagick gurus... I need some help please...

I have 4 jpeg images in a base layer as follows:
- 100x100 pixels: top_left.jpg
- 100x100 pixels: top_right.jpg
- 100x100 pixels: bottom_left.jpg
- 100x100 pixels: bottom_right.jpg

I have 2 transparent png's in 2 layers above:
- 200x200 pixels: overlay1.png
- 200x200 pixels: overlay2.png

I want to overlay the 2 transparent png images across the top of the 4 joined jpeg images and save the result as 4 jpegs again. Preferably using a single command with quality options too.

I'm faffing around like a crisp packet in the wind trying to do this. Please help.

I'm using the command line tools on a mac by the way.

Thanks for any help or pointers.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-03T19:46:18-07:00
by snibgo
I don't understand "and save the result as 4 jpegs again". 4 different jpegs? Just different qualities, or showing different things?

Anyhow, it might be something like this, untested, Windows syntax:

Code: Select all

convert ^
  ( top-left.jpg top-right.jpg +append ) ^
  ( bottom-left.jpg bottom-right.jpg +append ) ^
  -append ^
  overlay1.png -composite ^
  overlay2.png -composite ^
  -quality 50 +write out1.jpg ^
  -quality 60 +write out2.jpg ^
  -quality 70 +write out3.jpg ^
  -quality 80 +write out4.jpg ^
  null:
For Unix, use \ instead of ^.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-03T19:54:42-07:00
by Jezza
Sorry for the lack of clarity in my question snibgo - actually, output files will need to overwrite the original 4 jpegs.
Thanks very much for giving me the example code - it's taking me a while to get my head around the CLI syntax. I need to go and play with this.

Kind Regards,
Jez

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-03T20:13:02-07:00
by snibgo
If you want to divide the output into 4 equal tiles, "-crop 2x2@" will do that. But I don't see why you want to append images, then chop them up again.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T04:22:33-07:00
by Jezza
snibgo wrote:If you want to divide the output into 4 equal tiles, "-crop 2x2@" will do that. But I don't see why you want to append images, then chop them up again.
Again, sorry Snibgo for not doing a great job of explaining my problem. Hopefully this will help...

https://www.dropbox.com/s/xxx8ol7yziwrh ... e.png?dl=0

Starting with the four corner png's, I want to overlay 2 bigger png's and save to 4 new corner jpegs.

I'll need to down-sample the overlays too if this is possible in one go?

Is all this possible in one go?

Many thanks.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T04:50:24-07:00
by Jezza
Image

Trying to post an image here to explain my task. Preview not showing, but hopefully posting will show it.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T04:51:32-07:00
by snibgo
For the lines ...

Code: Select all

  overlay1.png -composite ^
  overlay2.png -composite ^
... you could have ...

Code: Select all

  ( overlay1.png -resize AxB ) -composite ^
  ( overlay2.png -resize CxD ) -composite ^
where A, B, C and D are whatever you need. See http://www.imagemagick.org/script/comma ... php#resize

You could also add shadows, but get the basics working first.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T09:22:09-07:00
by Jezza
hi snibgo, the following gives me 4 new jpegs which contain the same pixels as overlay2.png

convert \
\( top-left.png top-right.png +append \) \
\( bottom-left.png bottom-right.png +append \) \
-append \
overlay1.png -composite \
overlay2.png -composite \
-quality 50 +write out1.jpg \
-quality 60 +write out2.jpg \
-quality 70 +write out3.jpg \
-quality 80 +write out4.jpg \
null:

Do I need another append somewhere?

I hope this image explains my intention, and yes, I can do drop shadows once I've got the basics...
Image

Many Thanks,
Jez

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T09:42:30-07:00
by snibgo
As I said upthread, "-crop 2x2@" will divide the image into 4 equal tiles.

Code: Select all

convert \
\( top-left.png top-right.png +append \) \
\( bottom-left.png bottom-right.png +append \) \
-append \
overlay1.png -composite \
overlay2.png -composite \
-crop 2x2@ ^
-quality 50 +write out_%02.jpg \
null:
This should make out_00.jpg, out_01.jpg etc.

(But don't use JPEGs unless you really have to.)

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T10:14:14-07:00
by Jezza
Very nice - getting real close now! Thanks snibgo!

Is it possible to specify each of the output filenames separately?
Is is possible to scale one of the overlay images as part of this same command?

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-04T10:24:38-07:00
by snibgo
For scaling, like I said upthread. See my post starting "For the lines ..."

For specifying four different output names, yes, it can be done in IM, but it's a bit messy (using clone, write, delete). I would rename in the script.

Re: Advise please: Join -> Overlay -> Flatten -> Split again ?

Posted: 2015-03-07T18:34:09-07:00
by Jezza
Perfect. Many thanks for your help snibgo - the script and advise above has really helped me.