Can't append vertically?

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
jhfry

Can't append vertically?

Post by jhfry »

Windows bat script:

Code: Select all

convert ^
	( ^
		-size 1280x1024 ^
		xc:none ^
		-gravity center ^
		-font Palatino-Linotype-Bold ^
		-pointsize 20 ^
		-density 96 ^
		-fill white ^
		-stroke black ^
		-annotate 0 "Small Text" ^
		( ^
			+clone ^
			-background black ^
			-shadow 70x2+2+2 ^
		) ^
		+swap ^
		+composite ^
		-trim ^
		-gravity north ^
	) ^
	( ^
		-size 1280x1024 ^
		xc:none ^
		-gravity center ^
		-font Palatino-Linotype-Bold ^
		-pointsize 45 ^
		-density 96 ^
		-fill white ^
		-stroke black ^
		-annotate 0 "Large Text" ^
		( ^
			+clone ^
			-background black ^
			-shadow 70x4+5+5 ^
		) ^
		+swap ^
		+composite ^
		-trim ^
		-gravity north ^
	) ^
	+append ^
output.png 
Works, the two shadowed text blocks are appended horizontally.

If I change the +append to -append to append them vertically, I get two separate images called output-1.png and output-2.png. I don't get it, why can it do it horizontally but not vertically?

I experimented with changing the text of the second line and it works so long as the first layer is wider than the second. I don't understand why there is a restriction, or how to work around it! This will eventually be used in a script and therefore I cannot statically assign any sizes. I also tried doing a +swap just before the -append... and again it works as the top layer is larger than the bottom when they are swapped.

I am guessing that append will not allow an increase in the width during a vertical append, though it does allow an increase in height during a horizontal append. Perhaps its a bug?

Help please!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Can't append vertically?

Post by anthony »

A few things first off.
  • +composite should be -composite, though that should make no difference.
  • Also -gravity north at the END of the parenthesis blocks, does not do anything there, it really should be placed before the append, which is where it is actually used.
I converted the script to linux, replaced the +append with -append and for some reason it is not applied at all!

Looks like a gravity related bug, as when I remove the -gravity north is started working, adding -gravity north or -gravity center before the -append and it fails again.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
jhfry

Re: Can't append vertically?

Post by jhfry »

Trust me, I tried that... here is my simplified code:

Code: Select all

convert ^
	( ^
		-size 1280x1024 ^
		xc:none ^
		-gravity center ^
		-font Palatino-Linotype-Bold ^
		-pointsize 20 ^
		-fill white ^
		-annotate 0 "Small Text" ^
		( ^
			+clone ^
			-background black ^
			-shadow 70x2+2+2 ^
		) ^
		+swap ^
		-composite ^
		-trim ^
	) ^
	( ^
		-size 1280x1024 ^
		xc:none ^
		-gravity center ^
		-font Palatino-Linotype-Bold ^
		-pointsize 45 ^
		-fill white ^
		-annotate 0 "Large Text" ^
		( ^
			+clone ^
			-background black ^
			-shadow 70x4+5+5 ^
		) ^
		+swap ^
		-composite ^
		-trim ^
	) ^
	-append ^
output.png 
Still the same problem. If I take out the "-gravity center" from each line of text, I get a single image output... but much of each line is cut off. (I placed the text at the center of a large canvas to ensure that none of it gets clipped when it is shifted by -shadow).

Each of the two output images are exactly what I'm looking for... but I cannot have them append in the correct order. I can put the "large text" line above the "small text" line... or I can append them horizontally. It's really strange.

Is there a way to trim each line vertically but not horizontally... then I'd have two 1280x?? layers that should append vertically just fine... then I could simply trim again after appending them.

Thanks for your help!
Last edited by jhfry on 2008-12-30T07:38:49-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Can't append vertically?

Post by magick »

The problem you reported is fixed in ImageMagick 6.4.8-3 Beta available sometime tomorrow. Thanks.
jhfry

Re: Can't append vertically?

Post by jhfry »

Thanks Magick... I thought I was going crazy!
Post Reply