..trying to do resize img2 using img1's dimensions
i.e. kinda like; convert -resize img2.jpg img1.%w\ximg1.%h!
..tried setting the %w %h vars w/ -label, -size, etc, but cant get it to store them
use dimensions from one image to resize another
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: use dimensions from one image to resize another
You can use two lines: get size, then use it:mrmernan wrote:..trying to do resize img2 using img1's dimensions
i.e. kinda like; convert -resize img2.jpg img1.%w\ximg1.%h!
..tried setting the %w %h vars w/ -label, -size, etc, but cant get it to store them
size=`convert rose: -format "%wx%h" info:`
convert logo: -resize "$size" logo_rose.png
or combine them into one line:
convert logo: -resize "$(convert rose: -format "%wx%h" info:)" logo_rose.png
Examples above use rose: and logo: built-in images. So you can try it.
Re: use dimensions from one image to resize another
thanks! ..couldnt get your example to work via our fussy linux/tcsh environment (when used verbatim) , but your basic idea did inspire me to this;
convert infile2.jpg -resize `identify infile1.jpg -format "%wx%h!"` outfile.jpg
thanks again!
convert infile2.jpg -resize `identify infile1.jpg -format "%wx%h!"` outfile.jpg
thanks again!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: use dimensions from one image to resize another
Eventually (probably with IM v7) you will be able to do this more directly, but for now you will need to use two commands.
An API interface, like PerlMagick, IMagikc, or Rmagick, can do this more directly.
An API interface, like PerlMagick, IMagikc, or Rmagick, can do this more directly.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: use dimensions from one image to resize another
mrmernan wrote:thanks! ..couldnt get your example to work via our fussy linux/tcsh environment (when used verbatim) , but your basic idea did inspire me to this;
convert infile2.jpg -resize `identify infile1.jpg -format "%wx%h!"` outfile.jpg
thanks again!
Yes, identify and convert can both be used to get string formats. So
convert infile2.jpg -resize `convert infile1.jpg -format "%wx%h!" info:` outfile.jpg
should work also.
On some systems, at least from what I can tell,
`...` is the same as $(...)
You may get some faster results adding -ping, so that the image does not have to be read in.
convert infile2.jpg -resize `identify -ping -format "%wx%h!" infile1.jpg` outfile.jpg
See
http://www.imagemagick.org/Usage/basics/#controls