Crop and reduce image files using convert

The Matrix: Reloaded

I uploaded 23 some image files to the computer like above drawing.
The Bash script crop each image to 2967×2036 out of 3888×2592 resolution, reduce to 880×660, save it to IMG_*.jpg file.

convert $file -crop 2967×2036+605+551 -resize $resolution “${file/.JPG}”.jpg

I picked up common canvas size for all the images by physically examine few images using GIMP. 2967 is width, 2036 is height of the new image, and (605, 551) is starting position of the cropped image.

“${file/.JPG}”.jpg replace JPG extension to jpg because most websites I upload prefer lowercase letter.

After that I increased the contrast of all image files before uploading to the site.

convert IMG_*.jpg -level 20%,100% d*.jpg

All the images were reduced to 880×660 resolution, file size is about 200KB which is ten to twelve times smaller than original image. Here is one of final image file.

$ more resizejpg


if [ $# -ne 1 ]
echo "Usage: `basename $0` resolution"
exit 1

for file in *.JPG;
echo reduce $file to "$resolution"
convert $file -crop 2967x2036+605+551 -resize $resolution "${file/.JPG}".jpg

About janpenguin

Email: k2.mountain [at] gmail [dot] com Every content on the blog is made by Free and Open Source Software in GNU/Linux.
This entry was posted in GNU/Linux, Photography and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s