Image resizing tool for Ubuntu

Please try to use ImageMagick. First, install it:

$ sudo apt-get install imagemagick

Then you can make a little bash script to convert them to your 6 sizes:

#!/bin/bash

# List all the formats you wish to have
SIZES="640x480 800x600 1024x768"

# pass directory as first argument to the script
# Use '.' (current directory) if no argument was passed
DIR=${1:-.}

find $DIR -type f | while read file; do
   for size in $SIZES; do
      # Resize and rename DSC01258.JPG into DSC01258_640x480.JPG, etc.
      # Remove the ! after $size if you do not wish to force the format
      convert -resize "${size}!" "$file" "${file%.*}_${size}.${file##*.}"
   done
done

Save the script as, e.g. convert.sh, and run:

chmod +x convert.sh
./convert.sh /path/to/directory # path is optional, it takes '.' as default

Edit: I edited the script to make sure to not override files when resizing, but rename them to e.g. DSC01258_640x480.JPG, and use convert instead of mogrify since the files are actually renamed. I also sanitized the variables a bit, doesn't hurt.

I tested the script with png files and it worked fine. It should work for all kinds of image formats supported by ImageMagick:

$ file wave_bible_bot/*
  wave_bible_bot/wave_bible_bot1.png: PNG image, 516 x 308, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot2.png: PNG image, 515 x 428, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot3.png: PNG image, 565 x 384, 8-bit/color RGB, non-interlaced

$ ./resize.sh wave_bible_bot/

$ file wave_bible_bot/*
  wave_bible_bot/wave_bible_bot1_1024x768.png: PNG image, 1024 x 768, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot1_640x480.png:  PNG image, 640 x 480, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot1_800x600.png:  PNG image, 800 x 600, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot1.png:          PNG image, 516 x 308, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot2_1024x768.png: PNG image, 1024 x 768, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot2_640x480.png:  PNG image, 640 x 480, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot2_800x600.png:  PNG image, 800 x 600, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot2.png:          PNG image, 515 x 428, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot3_1024x768.png: PNG image, 1024 x 768, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot3_640x480.png:  PNG image, 640 x 480, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot3_800x600.png:  PNG image, 800 x 600, 8-bit/color RGB, non-interlaced
  wave_bible_bot/wave_bible_bot3.png:          PNG image, 565 x 384, 8-bit/color RGB, non-interlaced

If you install ImageMagick as Sathya mentioned, there is a nice GUI frontend to make resizing easier called nautilus-image-converter.

To install it:

sudo apt-get install nautilus-image-converter

Restart nautilus (or log out and back in). It will add "Resize Images" and "Rotate Images" to your context menu as shown here:

alt text

Simply highlight all images you want to resize, right-click, select Resize Images, and you will get this interface:

alt text

Use the "Append" option and add a custom name to your resized images. You may want to append the size such as 1024x768 OR you can make 6 copies of your images in different folders, then use the resize images in place option on the images in each folder to overwrite them with new images that have different dimensions. Resize images in place will always overwrite the selected images, so be careful what you select!


You can use ImageMagick: First install ImageMagick

sudo apt-get install imagemagick

Next, cd to the location where your images are there:

cd /path/to/where/images/are/stored

Next, create directories according to your Imagesize

mkdir /path/to/where/images/are/stored/size

Copy the images to the directory where you wish to transform

cp /path/to/where/images/are/stored/* /path/to/where/images/are/stored/size

Next, change the directory to the other directory

cp /path/to/where/images/are/stored/size

Then, use a tool called mogrify provided by ImageMagick library to resize

mogrify -resize 640×480! *.jpg

This will resize all to 640*480, ! tells to force aspect ratio.

I don't know Bash scripting, so its not that automated.

Tags:

Ubuntu

Images