Interesting Tech Projects
Posts tagged scripts
Resizing Images for Email in gThumb
Dec 26th
I wanted an easy way to resize images for email after importing them from a digital camera when using Gnome. Gnome by default uses gThumb for the import and it seems like an easy to use program. The problem is that in order to resize images several mouse clicks are needed, followed by a file rename.
So I wrote this quick little script to perform the resizing for me. Note that it only works with one picture at a time. To install copy to somewhere like /usr/share/scripts and make sure it is executable by everyone (sudo chmod 755 /usr/share/scripts/resizeimage
). Then in gThumb go to the preferences and click on the Hotkeys tab. Add the following to one of the hotkeys (I used zero):
/usr/share/scripts/resizeimage %f %n %e
Then in gThumb select an image and press the hotkey (on the numeric keypad). The image will be resized and renamed in one step.
The script is written to resize the image so the longest side is 800 pixels, while maintaining the aspect ratio. You need to have ImageMagick installed. If the original image is called foo.jpg, then the resized image will be called foo.resized.jpg, just like the Nautilus Image Converter does.
#!/bin/bash
# resizes an image for email, preserving aspect ratio
# requires imagemagik
# call: resizeimage /home/andy/foo.jpg /home/andy/foo .jpg
# in gthumb: resizeimage %f %n %e
convert "$1" -resize "800x800>" "$2.resized$3"