Jump to content

resizing a directory of jpgs [solved]


Recommended Posts

ok, I have a directory of jpg's. Instead of opening them up one by one in the gimp and resizing them, how do I resize a whole directory by file type? I know there's a way but I'm missing something in my command. I would imagine that this would be helpful if someone had a directory of more than 10.

 

so far, the closest I got were these 2 different commands which did the same thing. They both created a set of resized images and 2 sets of duplicates of the original size. What am I missing?

 

mogrify -size 3072x2048 -resize 800x600 +profile "*" *.jpg

convert -size 3072x2048 *.jpg -resize 800x600 *.jpg

 

[moved from Tips & Tricks by spinynorman]

Link to comment
Share on other sites

#! /bin/bash
DIRECTORY=/home/joe/images
for format in 'jpg' 'png'
do
 for image in `ls $DIRECTORY/*$format`
 do
   convert -resize 800x600 $DIRECTORY/$image
 done
done

 

that's a quick script, should work..

put it whereever, change DIRECTORY, then run it

and it *should* work, i havnt got anything to test on.

 

any bets aru upstages me with a one liner ;)

Link to comment
Share on other sites

find . -iname "*.jpg" -exec sh -c 'convert -size 800x600 "${1}" -resize 800x600 +profile "*" "${1//.jpg/-new.jpg}"' {} {} \;

 

or just

 

find . -iname "*.jpg" -exec sh -c 'convert -size 800x600 "${1}" -resize 800x600 +profile "*" "${1}"' {} {} \;

 

if you don't want to save the old one.

Link to comment
Share on other sites

find . -iname "*.jpg" -exec sh -c 'convert -size 800x600 "${1}" -resize 800x600 +profile "*" "${1}" && echo "`basename ${1}` resized"' {} {} \;

 

This one works. I've tested it. Copy and paste it. This one will overwrite the old. All I did was add echoing some output so you can see that it is doing something.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...