Need help on the resize and -composite in 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
olaola
Posts: 11
Joined: 2013-07-29T08:27:28-07:00
Authentication code: 6789

Need help on the resize and -composite in convert

Post by olaola »

Hello,

I wrote command like this:

Code: Select all

convert firstimage.jpg -auto-orient -crop 2508x1791+321+320 stickerimage.png -resize 627 -geometry 600x400+827+1171 -composite -quality 98.0 -density 300 output.jpg
my puopose is to resize the stickerimage.png and put it on the firstimage.jpg with the geometry parameters, but the result is, the resize happened on the firstimage.jpg which lead to the output.jpg only with 600 in width, please help me, i tried to add () arount the stickerimage.png, but it gave me error, how can I change this command to work as I expect, please help.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Need help on the resize and -composite in convert

Post by GreenKoopa »

Welcome. Platform and version?
olaola
Posts: 11
Joined: 2013-07-29T08:27:28-07:00
Authentication code: 6789

Re: Need help on the resize and -composite in convert

Post by olaola »

GreenKoopa wrote:Welcome. Platform and version?
latest windowns binary on win7 x64.

i think i got it by myself, just remove the -resize seems working, don't know why, i am testing with more cases.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Need help on the resize and -composite in convert

Post by Bonzo »

For a start this looks wrong to me as you should just have an offset:

Code: Select all

-geometry 600x400+827+1171 
Should be
-geometry +827+1171
Posting the error may have given more information

Try this:

Code: Select all

convert ( firstimage.jpg -auto-orient -crop 2508x1791+321+320 ) stickerimage.png -resize 627x -geometry +827+1171 -composite -quality 98 -density 300 output.jpg
olaola
Posts: 11
Joined: 2013-07-29T08:27:28-07:00
Authentication code: 6789

Re: Need help on the resize and -composite in convert

Post by olaola »

Bonzo wrote:For a start this looks wrong to me as you should just have an offset:

Code: Select all

-geometry 600x400+827+1171 
Should be
-geometry +827+1171
Posting the error may have given more information

Try this:

Code: Select all

convert ( firstimage.jpg -auto-orient -crop 2508x1791+321+320 ) stickerimage.png -resize 627x -geometry +827+1171 -composite -quality 98 -density 300 output.jpg
you are right, just keep offset works fine, but the parenthesis should be placed on the 2nd image

Code: Select all

 convert firstimage.jpg -auto-orient -crop 2508x1791+321+320 (stickerimage.png -resize 627) -geometry +827+1171 -composite -quality 98 -density 300 output.jpg
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Need help on the resize and -composite in convert

Post by GreenKoopa »

A space is required around every ( and ) .
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Need help on the resize and -composite in convert

Post by anthony »

-geometry has two actions (historical reasons)
It resizes tha current last image, and saved the offset for composition.

See IM Examples, Resize, Geometry
http://www.imagemagick.org/Usage/resize/#geometry


You use geometry after reading the first image, so of course that is the image it resized (the only image in memory)

using -geometry for resizing is NOT recommended.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply