How-to: Batch-resize a group of images.

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
Fossil
Posts: 1157
Joined: Tue 13 Dec 2005, 21:36
Location: Gloucestershire, UK.

How-to: Batch-resize a group of images.

#1 Post by Fossil »

Most people who own a computer also have a digital camera. The increasing size of digital memory cards means there's no constraint on the number of images that can be taken at any one time. In consequence, after a day out at an interesting venue, there's usually a large number of pictures to be looked through and resized for easier viewing or emailing off to friends and relatives. A few minutes work on just one image, can now escalate into a couple of hours of manually resizing lots more. How best to automate the slow repetitive routine?

Before anything else. When working with digital photos it always pays to manipulate a copy rather than the original picture. Copy the memory card's contents to a folder on the hard drive. It is also a lot easier to use a simple multicard reader, than attempting to copy a lot of pictures from the camera via a lead plugged directly into the computer. There's always the possibility the camera's batteries might fail half-way through the operation. Images can sometimes become corrupted. Knowing 'Murphy's Law', it's always the irreplaceable ones!

First. Download the resizing and image enhancing program, aaphoto.
http://puppylover.netsons.org/dokupuppy ... age_editor
Or, the home website:
http://log69.com/index_en.html

Copy aaphoto to /usr/bin.

Use a text editor to write a simple bash script.
#!/bin/bash

aaphoto "$@" -a -r640 -q75
The meaning: auto-adjust image tones, resize to 640 pixels, using 75% quality.

Save the script in /usr/bin with an easily identifiable name, 'Photo-resize_x640'. Right-click on the script. Properties. Under 'Permissions' tick the box, 'Exec'. 'Refresh', then Close. It's easy to make up several, with different resize options. For convenience, simply drag the script('s) out onto the desktop.

To resize pictures. Select the ones required, drag and drop the images onto the bash script. The selected images will be resized and placed within the same folder as the originals, with 'new' added to the resized image.

***

Alternatively, method 2.
Having already made up your resize scripts.
Right-click on an image. When the menu appears, go to, 'Open With'.... 'Customise'. Then, Control-Shift-Drag one or more of the resizing bash scripts from /usr/bin into the open menu selection.
The next time any pictures need to be resized, hilight the images required, right-click, 'Open-With', select the preferred script from the menu. Automatic resizing will then commence.

***

Alternatively, method 3.
In GQview it's even easier.
Go into, Edit, Options, Editors. Type a name for the program in the Menu, such as, "Aaphoto - Resize-x640", etc. Then add this line of code for the Command line. aaphoto %f -a -r640 -q75

It's also a simple matter to change the -r640 to a larger size, such as, -r800, or -r1024. The same for the quality setting. -q85, etc.
Finish by clicking on, 'Apply', 'OK'.
Using GQview, go into the folder in which you have stored the copied photos. Hilight all (Control-A) or whatever individual ones you want (Control, left mouse-click).Go back up to Edit, select the menu for Aaphoto - Resize-x640, etc. And that's it. Aaphoto will now begin resizing all the selected images, adding the suffix 'new' to the resized pictures.

***

Renaming.

If there's a need to add a more meaningful description to the pictures, use Rox. Hilight all (Control-A), then right-click, Rename.
Use the left-hand upper box, Replace. Tip: Hover the cursor over the space, which reveals some hints. To add a name at the start of the image, use ^ then type a short name/outline detail in the right hand box, 'With'. Click on, 'Apply'. Look at the effect, if it's suitable, click on 'Rename'. That's it!
Far easier than renaming one-by-one.

Have fun! :wink:
Last edited by Fossil on Tue 24 Jun 2008, 16:24, edited 2 times in total.

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#2 Post by Dingo »

very interesting and useful, a post you must sticky!
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

User avatar
Fossil
Posts: 1157
Joined: Tue 13 Dec 2005, 21:36
Location: Gloucestershire, UK.

#3 Post by Fossil »

Thank's Dingo,

If it wasn't for you posting aaphoto, I'd still be trawling through 100+ images by hand :?

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#4 Post by Dingo »

only a question: since aaphoto create resized images in the same directory, how you separate resized images from original? for the rest, it's true that aaphoto is very powerful as resizing tool
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

User avatar
Fossil
Posts: 1157
Joined: Tue 13 Dec 2005, 21:36
Location: Gloucestershire, UK.

#5 Post by Fossil »

how you separate resized images from original?
Right-click, Display, Sort-by-Date. The newest ones will be last - separating old originals, and the new resized copies. Draw a bounding box with the cursor around the ones you want; if there's a couple out of reach, use Control, and mouse-click on the stragglers. Copy, or move, to another folder.

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#6 Post by muggins »

Fossil & Dingo,

running from the commandline this works for me:

Code: Select all

#!/bin/bash
directory=`pwd`                                                                
                                                                               
mkdir original                                                                 
mkdir resized                                                                  
for file in $directory/*.jpg                                                   
do                                                                             
        aaphoto $file -a -r640 -q75                                            
        mv $file original                                                      
done                                                                           
mv *.jpg resized 

User avatar
davidA
Posts: 64
Joined: Sun 15 Jun 2008, 04:55
Location: Location: Location:

#7 Post by davidA »

muggins wrote:Fossil & Dingo,

running from the commandline this works for me:

Code: Select all

#!/bin/bash
directory=`pwd`                                                                
                                                                               
mkdir original                                                                 
mkdir resized                                                                  
for file in $directory/*.jpg                                                   
do                                                                             
        aaphoto $file -a -r640 -q75                                            
        mv $file original                                                      
done                                                                           
mv *.jpg resized 
So: now I realize I have to hone up on my shell scripting skills (or at least my skills when using the command line) :(

And that is supposed to be a compliment muggins 8)

User avatar
rarsa
Posts: 3053
Joined: Sun 29 May 2005, 20:30
Location: Kitchener, Ontario, Canada
Contact:

#8 Post by rarsa »

This is very similar to what I was doing but requires less HDD.

Here is what I was doing:

I installed ImageMagick

and created the following script

Code: Select all

cd "$1"
smallDirName="small$(basename $1)"
mkdir "${smallDirName}"
for picture in *.jpg
  do convert "$picture[640x480]" "${smallDirName}/$picture"
done
cd "$1"
montage -tile 5 -geometry +4+4  -label "$1" -font Verdana -pointsize 10 -quality 30  "*.jpg[160x120]"  __index.jpg
Which does the resize plus creates an index file.

I created a batch file for windows and a script file for linux, both work the same way.

You just drag a folder with jpeg files and it creates a subfolder with "small" prefixed with all the resized images.
Last edited by rarsa on Wed 25 Jun 2008, 15:46, edited 1 time in total.
[url]http://rarsa.blogspot.com[/url] Covering my eclectic thoughts
[url]http://www.kwlug.org/blog/48[/url] Covering my Linux How-to

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#9 Post by MU »

here is a very small and simple to use batch-converter I wrote a month ago:
http://murga-linux.com/puppy/viewtopic.php?t=29184
Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

firak
Posts: 175
Joined: Mon 14 Apr 2008, 14:07

THAKS FOSSIL

#10 Post by firak »

I will try it. :?:
actuaaly for work with oofice document with immages, beforare insert the immage, this is very inportant, to not oversize the kb of the document.
I did not found yet in the programs of puppy & also in gimpshop, a short way to restrize immages. so thaks, i will try it......
i ALREADY TRY IT IT WORKS. :roll:
very inportant for eepc, very usefool for office document
It is amazing how easy is life with such friendly open sourece people :idea: , instead of MS win.


Post Reply