Share your knowledge at the LQ Wiki.
Go Back > Blogs > sag47
User Name


Rate this Entry

Convert and resize images using imagemagick

Posted 05-30-2011 at 10:07 PM by sag47
Updated 05-31-2011 at 01:23 AM by sag47

This past memorial day weekend I took a bunch of pictures which I wanted to post to the web. Web photos are best viewed in 800x600px and I had a lot of them. So I used a simple command to do it.
for x in `ls -1`;do convert -resize 800x600 $x `echo $x | sed 's/.JPG/.png/'`;done
mkdir web_album
for x in `ls -1 *.png`;do convert $x web_album/`echo $x | sed 's/.png/.jpg/'`;done
rm *.png
Now I don't have to spend all my time in Gimp with that simple batch command.
Posted in Uncategorized
Views 6942 Comments 1
« Prev     Main     Next »
Total Comments 1


  1. Old Comment
    Just resized pictures 25% smaller and used a better way to change extensions which I outlined in this thread.

    for x in *.JPG;do convert -resize 25% $x processed/${x%.JPG}.jpg;done
    ${x%.JPG} takes .JPG off of the end of the variable $x which allows me to rename all the pictures from .JPG to .jpg extension with the following variable "${x%.JPG}.jpg"
    Posted 03-03-2012 at 05:28 PM by sag47 sag47 is offline
    Updated 03-03-2012 at 05:32 PM by sag47


All times are GMT -5. The time now is 01:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration