[PLUG] Resizing images with imagemagick
Ben Koenig
techkoenig at gmail.com
Tue Apr 23 20:37:08 UTC 2019
On 4/23/19 12:30 PM, Rich Shepard wrote:
> On Tue, 23 Apr 2019, Ali Corbin wrote:
>
>> It'll take human intervention, to look at each individual image and
>> decide
>> whether to rotate it.
>
> Ali,
>
> This I knew. I usually use the GIMP for this manipulation and am glad to
> learn that ...
>
>> Happily, it's not too onerous to do this in imagemagick, using the
>> 'display' command.
>>
>> This will bring up the first jpg in the directory as the start of a
>> slideshow.
>> display *.jpg &
>>
>> Then you can hit the space bar to cycle through the images. '/' or '\'
>> will rotate the image that you're looking at, and Ctrl-S will save it.
>
> And once they're all properly oriented I can use convert's -resize
> option to
> change all in the same subdirectory.
>
> Much appreciated,
>
> Rich
> _______________________________________________
> PLUG mailing list
> PLUG at pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
BTW, the identify tool does this. It's part of IM as are a number of
other image processing commands.
Get the size of the image using
$ identify -format "%wx%h\n" /path/to/image
in the -format string
%w is the pixel width
%h is the height
\n is to print a newline, otherwise it clobbers your prompt.
Without -format it prints out a lot of stuff, see
https://www.imagemagick.org/script/escape.php for more options in
trimming the output of identify.
Once you have an identify command that is scriptable, a BASH becomes trivial
------
$aspectratio = identify $image
IF [ $aspectratio is wrong ]; THEN
convert $image $newaspectratio
convert $image $newscale
ELSE
convert $image $newscale
FI
------
Just pounding out pseudocode so that we are aware that YES, imagemagick
can do this for you.
More information about the PLUG
mailing list