how to resize image A.png according to B.png?

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
liizii
Posts: 7
Joined: 2011-07-12T06:34:00-07:00
Authentication code: 8675308

how to resize image A.png according to B.png?

Post by liizii »

e.g. B.png width is x, height is y. and how to resize A.png to x*y
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: how to resize image A.png according to B.png?

Post by whugemann »

I think you cannot do this in one run; you have to write a script that
  • 1) identifies the dimensions of image A and stores the result in a variable
    2) resizes image B according to these values
How exactly this has to be done depends on your OS (which you didn't mention) and the script language you want to use.
Wolfgang Hugemann
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to resize image A.png according to B.png?

Post by anthony »

Basically correct. You need two steps, extract size of image B and resize image A (turn off aspect ratio preservation if that is a problem.

It can be done in one command using -distort Affine, where the viewport and distort parameters are set from another image, but that is very very tricky.

Basiccly combining.. Im Examples, Tranform Images, Accessing data from another image
http://www.imagemagick.org/Usage/transform/#fx_other
With something like Distort Resize, Internals
http://www.imagemagick.org/Usage/distorts/#resize

NOTE you will have to use the 'internals method' as the Distort Resize method uses a geometry string that can not use 'percent escapes', and really should be a resize operator, that is separate to distort.


IMv7 will have more direct facilities to use percent escapes in operatiosn such as resize, making this a lot easier.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply