Batch CROP and resize jpg images

Hi there,

I have a bunch of photos in various aspect ratios (4:3, 16:9, etc.) that I’d like to crop to 4:3 and resize to 800 x 600, to use in an oldish digital picture frame.

IINM I used to do this in gwenview with kipi-plugins installed, but for some time now this doesn’t work, according to some old posts here it is a library version issue.

I also tried digikam but the bottom of wider photos (16:9) were padded with the bottom part of the previous 4:3 photos processed. A very weird behavior, or I did something very wrong.

I can batch rezise with something like

mogrify -resize 800x600 -format jpg *.jpg

But I can’t seem to find a way to batch crop the photos first.

Any suggestions?

Thanks,

Hi, you could try ImageMagic’s command:

convert -crop +100+10 in.jpg out.jpg

It crops 100 pixels off the left border, 10 pixels from the top.
More here: http://www.imagemagick.org/Usage/crop/#crop

Thanks GazetaCypr,

Your link led to other and eventually to a solution. You can crop to a fixed ratio, without changing resolution, with

convert *.jpg -gravity center -crop 4:3 *.jpg

This crop option is new in imagemagick 7.x, and doesn’t appear to be documented in the man pages yet.

There’s probably a better way to set the renaming, but this worked for me.

I found an application with gui in the graphic repositories to do image batch/crop resizing.
Might be of help to someone looking for an easy to use and without using
the commandline.:slight_smile:

The applcation name is called

BIR

Where is it?
https://software.opensuse.org/search?utf8=✓&baseproject=ALL&q=BIR

It is in the tumbleweed graphics repositories.
Just add the repo.
https://download.opensuse.org/repositories/graphics/openSUSE_TumbleweI only use it as needed then I turn it off because sometimes it creates dependency/conflicts
with the main tumbleweed repositories.

bir 2.0 founded: https://software.opensuse.org/package/bir

Hi,

I just wanted to add that I did some testing on converting those files and you can loop through the files and pad a cropped_ from the beginning of the file name.

for f in *.jpg; do convert "$f" -gravity center -crop 4:3 **"${f/#/cropped_}"**; done 

Or place the newly cropped files into another directory where the original jpg files are.

for f in *.jpg; do convert "$f" -gravity center -crop 4:3 "**/path/to/new/directory/${f/#/cropped_}**"; done 


Hi,

I just realized that “${f/#/cropped_}” is bashism, so not sure if will work with other POSIX compatible shells, It can be replace with just

**"cropped_$f"**