Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Need help resizing, and renaming a whole buttload of .jpg's
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Hamking
n00b
n00b


Joined: 05 Jul 2002
Posts: 67
Location: MN

PostPosted: Mon Mar 24, 2003 3:00 am    Post subject: Need help resizing, and renaming a whole buttload of .jpg's Reply with quote

Ok check it:

I had this totally bitchin party last weekend, and I took over 200 pics with my new digital camera. All the people at the party are yelling at me now to put up all the pics I took of the party on the net.

Ok, so I was wondering if it would be possible to come up with a script.. or some confusingly complicated(it can be simple too ;)) command to basicly convert all the pictures from the resolution they are at to about 50% , and then save them into another directory, with different, but repectively numerated filenames. I'm just going from .jpg to .jpg here, but scaling the image, and saving the new copy into another directory with a different file name.

Somthing like:dcp_0162.jpg, dcp_0163.jpg >>TO>> fun_party_001.jpg, fun_party_002.jpg, etc...

While at the same time scaling them down from 1800x1200 to 900x600

Could anybody help me with that???

Thanks :D
_________________
--Hamking :D
Back to top
View user's profile Send private message
Smiler
n00b
n00b


Joined: 02 Jul 2002
Posts: 10

PostPosted: Mon Mar 24, 2003 12:01 pm    Post subject: Reply with quote

wouldn't some sort of thumbnail soft. do the trick ?
Back to top
View user's profile Send private message
NePhie
Tux's lil' helper
Tux's lil' helper


Joined: 01 Sep 2002
Posts: 82

PostPosted: Mon Mar 24, 2003 12:11 pm    Post subject: Reply with quote

take a look at the imagemagick thingie ... it has a command "convert" which can do a shitload of stuff...and i really mean a shitload....i'm 100% sure one could come up with a command involving "convert" that does allready a part of that (the scaling part...say, do they all have to be the same res, or really something like "scale to 50%" ... i just KNOW it's gonna be easy with convert =) )

and then you wrap that command in a script wich loops all files in the directory, running that command on in with some variables (the "numbering" part)

if i'm not to lazy, i'll even look into it myself ! =)
_________________
.:: $witty_statement ::.
Back to top
View user's profile Send private message
NePhie
Tux's lil' helper
Tux's lil' helper


Joined: 01 Sep 2002
Posts: 82

PostPosted: Mon Mar 24, 2003 1:05 pm    Post subject: I wasn't too lazy Reply with quote

it might be not the best code around, but it's more than decent enough

very generic script that will allow you to resize any type of image in any directory to any other directory with any target "base-filename" ..check if enough parameters are given, if not it shows what it should be

Code:

#!/bin/bash

#test for the parameters that were given
if [ $# -eq 5 ]
then
        #get us an initialized counter variable
        counter=0

        #loop that will go trough all files that end in .jpg in the directory
        for file in $2/*.$1
        do
                #set the counter
                counter=`expr $counter + 1`

                #convert it to the given size (either res or % or ...), and save that new file in the other dir, with the other filename and counter
                convert $file -resize $4 $3/$5_$counter.$1
        done
else
        echo "You need to call this script with 5 arguments ->"
        echo "1. type of files (files must end with this) without the dot !! (ex. jpg)"
        echo "2. the directory where these files are located"
        echo "3. the directory where the new files should be saved"
        echo "4. what the images should be resized too (ex. 50% or 800x600, ...see the convert manpage)"
        echo "5. the new base-filename... this will be appended with "_" and a number (1 to ...)"
        echo
        echo "example --> resizer jpg /dir /other/dir 50% pics_at_half_size"
        echo
        echo "(ps. copy this script in /usr/bin and chmod +x it to be able to execute it like that)"
fi


hope you find it usefull =) (PLS keep in mind that you have to emerge imagemagick for this !! "convert" is in that package !)
_________________
.:: $witty_statement ::.
Back to top
View user's profile Send private message
tukem
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jun 2002
Posts: 114
Location: Tampere, Finland

PostPosted: Mon Mar 24, 2003 5:06 pm    Post subject: Reply with quote

If a less flexible solution is good enough instead of that script you could use a single line version:
Code:

ls *.jpg | xargs -iXX convert XX -resize $4 <save path>/<prefix>XX<postfix>


where $4 is new image size same as in previous script. The difference in this version is that it doesn't change the original file name. It's possible to add a prefix or a postfix to the name but otherwise it's the same.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum