linux.gotfoo.org

tips, tricks and howto’s

Categories

Search



Visit Xubuntu.org

Resize Multiple Images with a G-Script

August 10th, 2006 by jay
, , ,

Summary
scale_image_to_sizes is a quick and easy G-Script that can convert multiple images with a single Right-Click in Nautlius. It's very simple to use and very easy to modify to your needs.

Introduction
Being the in-house techie my wife employed me to create and maintain her High School Class Web site. (It shall remain annon because the design is really tacky. Like circa 1997 tacky.) And as things go most people do not get the concept that when they take a digital photo on a 4+mb camera that the photo file is quite large. Have you ever tried to explain that a photo that's 1152x864 is to large to display in a web page? Not to mention that the file size is pushing 1.5+MB. So every time my wife gets sent some photos to be posted on the site she'd send me the zip file with 10 or so photos all of which are pushing the 1152x864 / 1.5MB limit. I'd try to explain to her, for the billionth time, how to resize the photos (on her WinXP box) before sending them to me using the MS Picture Manager. This would result in her getting frustrated because I go to fast when explaining things. In the end I usually kick her out of her chair and convert the photos my self. If you want something done right.....

Ubuntu Hacks: Tips & Tools for Exploring, Using, and Tuning Linux (Hacks)

I have always found that doing these types tasks on a Windows box is easy because there is so much Windows software out there. But when it comes to Linux these tasks are still just as easy. The hard part is finding the tool to do it.

G-Script: scale_image_to_sizes
If you haven't got G-Scripts installed go here. Once you've got G-Scripts installed you'll see in scale_image_to_sizes the context menu:
Right-Click-> Nautlius Scripts-> Multimedia-> scale_image_to_sizes

You'll see another script, scale_image which is for a single image and works quite similar to scale_image_to_sizes.

Resize Images
Now that you know where the script lives let's resize some images.

  1. Using Nautilus navigate to an images directory
  2. Select 1 or more images by holding the Ctrl key while selecting each image
  3. Right-Click on the selected images and then
    Nautlius Scripts-> Multimedia-> scale_image_to_sizes
  4. A dialog box will pop up with a list of pre-defined image sizes (1600x1400 ,1280x1024, 1024x768, 800x600, 640x480) and choose the 6040x480
  5. Click OK and in a few seconds you'll new inage files appear with the image size pre-pended to the filr name (640x480ImageName.jpg)

When it's done double click one of the new resized images to see the result.

See very simple.

But 640x480 that's still kind of large.
No problem.

Hacking the G-Script
The thing I am loving about Nautilus and G-Scripts is the fact that I can adjust an application (a bash script) with out having to know any C/C++. I view G-Scripts like I view the web; in the end it's all just text. So with this G-Script scale_image_to_sizes we are going to add a new size to resize images to.

In Nautilus navigate to the hidden folder /.gnome2/Nautilus-Scripts/Multimedia. In the Multimedia folder you'll see the file scale_image_to_sizes.
Right-Click on it and then open it in gedit(or what ever text editor you like) .

You should see this:
*I've omitted the Language Selection for readability.*

CODE:
  1. #!/bin/bash
  2. title="Scale image"
  3. scale="Choose which sizes to scale to"
  4. imgsize=`gdialog --title "$title" --checklist "$scale" 200 100 6 1600x1400 " " off 1280x1024 " " off 1024x768 " " off 800x600 " " off 640x480 " " off 2>&1`
  5.  
  6. while [ $# -gt 0 ]; do
  7.     picture=$1
  8.     for i in $imgsize; do
  9.         i=`echo $i | sed 's/"//g'`
  10.         /usr/bin/convert -scale $i "$picture" "$i-$picture"
  11.     done
  12.     shift
  13. done

I can't go into a detailed explanation of this script because quite frankly I don't know bash that well. (But after 8 years at web development and programming one can look at almost any language and get the gist of it.)
What I do know is that this G-Script is a wrapper for the bash command convert and is passed the -scale parameter to indicate that this is an image. The new image size is a guideline that measures the image to determine if it is a landscape or portrait and then scales the picture accordingly.

The item we want to look at is the variable imgsize which will holds the value we selected from the list when resizing the images. For the sake of not breaking any thing we are going to change the 1280x1024 value to 400x350 and that's it.

CODE:
  1. imgsize=`gdialog --title "$title" --checklist "$scale" 200 100 6 1600x1400 " " off 400x350 " " off 1024x768 " " off 800x600 " " off 640x480 " " off 2>&1`

Now save the document and go back to Resize Images instructions but this time select the new image size.

Conclusion
As you can see this little script can save you time when you need to convert a lot of images at once. Sure there are GUI apps that do the same thing but this sweet baby is very simple, light weight and you can hack it up!!

Now when my wife sends me a zip file of images I just unpack it and then run scale_image_to_sizes. Once the images are ready I just upload them to the site and I'm done.

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • De.lirio.us
  • digg
  • Reddit
  • RawSugar
  • Furl
  • YahooMyWeb
  • Spurl
  • Ma.gnolia
  • NewsVine

Posted in Linux, HOWTO, Tips N Tricks, GNOME, G-Scripts |

6 Responses

  1. Shawn Says:

    Mate.. There's a faster way for your wife to resize pictures..

    I've written one here http://www.fishingkaki.com/forum/viewtopic.php?t=15620 and basically involves(in summary) installing a Windows XP Powertoy known as Image Resizer from Microsoft. After that, it's just a simple right click and "Resize Image".

  2. James Says:

    This is for Linux, more specifically Gnome, not Windows.... I think everyone knows about the powertoys add on

  3. FedoraGnomeNautilus Says:

    Ha,ha. Windows. Yea. Where the REAL power lies we both know buddy ey ????

    :-)

  4. glenn Says:

    late to the game here, but is there a similar feature that will simply let me re-scale the pixels per inch without re-sizing the picture?

  5. michuk Says:

    Another useful article on the subject: http://polishlinux.org/apps/graphics/enchanting-pictures-with-imagemagick/
    (massive resizing, adding text or frames to images, etc, all with ImageMagick)

  6. Bill Compton Says:

    Hi Jim. Photos i received. Thanks

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


aprons to buy + dallas samsung behold rose bene casa cookware lazzaroni amaretti di saronno ladies blouse bodysuit monkey stud earrings grade a, b, c maple syrup brands tortoise narrow bangle tuxedo scarf silk farberware FCP512S percolator ac delco 214 474 Fox Racing 2008 Model Women's Future Star Fur Lined Hoody electric cable hoist 1100 pounds books aztec woman newline electronic kitchen scales customer women's blouses philadelphia magazine of Ralph Waite buy sassafras extract The Beatles-"Let It Be" Documentary DVD date wooden wastebin boho holiday dessert plates new york yankees pink jeter jersey Nerf N-Strike Vulcan EBF-25 Blaster Value Pack Bianca Black and White Bath Towels bare escentuals hydrating mineral veil divina olive oil mega brand magnext toys champion cargo pants 30 MM METRIC INTERNAL LOCK WASHERS d-rex interactive dinosaur nike toddler soccer uniform grex pin nailer reviews CONAIR GLITTER bmx toys technine mfm bindings garage workshop photos peg board www.gpx pills.com Kinesio Tape at MaxiAids 11" toro brand electric weedeater RUBBERMAID ROOF BASKET beeko shoes Cookware Shop free XXX Teen XXX Hardcore dating guide black shemale latin porn asian shemale sex asian ass hardcore teen fuck free BBW dating tips discount shop brazzers porn levitra cialis cialis cheap cialis soft tabs natural viagra substitute vitamins herbs canadian pharmacy cheapest levitra price welivetogether nikki Nakole great swallow blowjob big naturals nikara anal mature redhead smoking sex amazing blow jobs girls with out there thongs on free transexual porn lesbian old woman porno drunk gangbang asian porn videos buy klipal buy viagra canadian rx pharmacy buy viagra generic cialis discount levitra free sample prescription for tenuate buy oxazepam online without prescription authorized online pharmacy valium Trazodon Xanax (tafil) 0.5mg 100 tabs tramadol shipment online approval no doctor lorazepam vs lorazepam zyban discount sale uk diazepam sales purchase cialis on line viagra soft tabs buy ordering viagra online levitra mail order uk viagra does viagra work for women cialis soft tabs uk porn movies pfizer viagra shipment online approval no doctor discount drug cialis soft tabs blue order pill viagra levitra prescription purchase viagra female cialis herbal cialis soft tabs same day shipping buying levitra canadian pharmacy generic viagra soft tabs on line buy generic viagra herbal viagra soft tabs in natural toronto cialis