Leading on from this topic:-
viewtopic.php?f=1&t=35471
and very similar to concepts discussed here:-
https://www.imagemagick.org/discourse-s ... hp?t=33209
Although, the condition is that it's simply a Windows BAT file and using IM6, would not involve any fancy scripting environment.
I would like to crop/resize an image to match the dimensions of another image, since the exact resolution could never be known for each case.
Although not involving fancy programming, storing and then retrieving info from a TXT file might do the trick? If IM has such a function?
I honestly have no idea but ideally it would be within one command and not involve extras, if it's possible at all?
Something like this ridiculous fantasy example:-
"convert input.png -resize(%w="match.png"x%h="match.png") output.png"
The fantasy result would be that output.png would be input.png but with the resolution of match.png.
[SOLVED]: Resizing/Cropping based on info from another image
[SOLVED]: Resizing/Cropping based on info from another image
Last edited by LDAsh on 2019-02-11T06:34:56-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resizing/Cropping based on info from another image
Code: Select all
for /F "usebackq" %%L in (`%IM%identify ^
-format "MYSIZE=%%wx%%h" ^
match.png`) do set %%L
echo MYSIZE=%MYSIZE%
%IM%convert input.png -resize %MYSIZE% output.png
snibgo's IM pages: im.snibgo.com
Re: Resizing/Cropping based on info from another image
Wow, too awesome. Got the resize and crop happening, and figured out how to separate the X and Y values all by myself. I guess I can just do ~unlimited values for and from whatever I want, it seems, anything I can get out of identify and into anything that can be fed a number. You've just helped me open up a whole bunch of new possibilities.
Very powerful stuff, cheers snibgo!
Very powerful stuff, cheers snibgo!