Page 1 of 1

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

Posted: 2012-04-12T02:03:10-07:00
by liizii
e.g. B.png width is x, height is y. and how to resize A.png to x*y

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

Posted: 2012-04-12T05:59:45-07:00
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.

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

Posted: 2012-04-13T05:20:48-07:00
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.