Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Batch resize nautilus script

  1. #1
    Join Date
    Sep 2005
    Location
    NL
    Beans
    5
    Hi,

    To batch resize all images in a folder, I do the following:

    Make a new file (not as root):

    Code:
    gedit ~/.gnome2/nautilus-scripts/batch640x480
    Then add the following:

    Code:
    #!/bin/sh
    # author: Bas Wenneker
    # email: sabmann [ta] gmail [tod] com
    # Use this script to batch resize all images in a folder.
    # First open the folder and then use the script.
    
    for file in `ls -l`
    do
    name=`echo $file | cut -f1 -d.`
      convert -geometry 640x480 -quality 65 $file ${name}_640x480.jpg
    done
    Then make it executable:

    Code:
    chmod +x ~/.gnome2/nautilus-scripts/batch640x480
    Then you're done. Go to the folder you'd like to resize. Then rightclick and find the 'batch640x480' script.
    I use this script for resizing large amounts of photo's for a website. That's why the '-quality 65' is in the script. You can change the script to your needs. Click here for more convert commands.

    Hope you'll find this usefull...

  2. #2
    Join Date
    Aug 2005
    Beans
    202

    Re: Batch resize nautilus script

    Does this resize other images besides .jpgs?

    For instance .svg?

  3. #3
    Join Date
    Sep 2005
    Location
    Quebec, Canada
    Beans
    33

    Re: Batch resize nautilus script

    Quote Originally Posted by linkunderscore
    Does this resize other images besides .jpgs?

    For instance .svg?
    You cannot resize a .SVG directly.. svg files have no defined size. They're just a XML file at all !

  4. #4
    Join Date
    Jun 2005
    Location
    USA
    Beans
    80

    Re: Batch resize nautilus script

    Thanks! I was looking for this. Since all the files I want to convert end in JPG, I changed 'ls -l' to 'ls | grep JPG' and it doesn't spit out a bunch of 'cannot find' things from ls. I've noticed though that the efficiency of the jpeg compressor in convert is not as good as the one gthumb uses. At quality setting 80, gthumb produces a file ~30 KB less. Oh well, it saves me a boatload of time

  5. #5
    Join Date
    Sep 2005
    Location
    NL
    Beans
    5

    Re: Batch resize nautilus script

    I changed 'ls -l' to 'ls | grep JPG'
    yes I tried your 'ls | grep JPG' but sometimes the extensions are different like .jpeg or the extension is in uppercase... so that's why I use the ls -l... But you are right about the cannot find * messages... I'll add it to my first post, thanks

  6. #6
    Join Date
    Nov 2004
    Location
    Southwest Missouri
    Beans
    217
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Batch resize nautilus script

    I got this script to work on Dapper. I made a couple of changes to the script so that it would save the new pictures into a separate directory that I called "thumbnails" instead of mingling them with my other pictures and also, I adjusted the picture size and quality to suit my preference. Also, I added the -strip argument so that it would strip out my exif information. My camera adds a lot of exif information and in my case, that saved me about 25-30kb per picture, which is a major difference for the web.

    Code:
    #!/bin/sh
    # author: Bas Wenneker
    # email: sabmann [ta] gmail [tod] com
    # Use this script to batch resize all images in a folder.
    # First open the folder and then use the script.
    mkdir ./thumbnails
    for file in `ls -l`
    do
    name=`echo $file | cut -f1 -d.`
      convert -strip -geometry 800x600 -quality 80 $file ./thumbnails/${name}_800x600.jpg
    done
    Last edited by lhtown; April 14th, 2006 at 09:11 PM.

  7. #7
    Join Date
    Mar 2006
    Beans
    53

    Re: Batch resize nautilus script

    Quote Originally Posted by lhtown View Post
    I got this script to work on Dapper. I made a couple of changes to the script so that it would save the new pictures into a separate directory that I called "thumbnails" instead of mingling them with my other pictures and also, I adjusted the picture size and quality to suit my preference. Also, I added the -strip argument so that it would strip out my exif information. My camera adds a lot of exif information and in my case, that saved me about 25-30kb per picture, which is a major difference for the web.

    Code:
    #!/bin/sh
    # author: Bas Wenneker
    # email: sabmann [ta] gmail [tod] com
    # Use this script to batch resize all images in a folder.
    # First open the folder and then use the script.
    mkdir ./thumbnails
    for file in `ls -l`
    do
    name=`echo $file | cut -f1 -d.`
      convert -strip -geometry 800x600 -quality 80 $file ./thumbnails/${name}_800x600.jpg
    done
    hey thanks lhtown for the updated version with quality difference and stating that you got it to work in dapper.
    haha note if you try and resize a movie file it resizes each frame.
    Last edited by Felix21685; October 9th, 2006 at 05:58 AM.

  8. #8
    Join Date
    Oct 2006
    Location
    Sacramento, California
    Beans
    529
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Batch resize nautilus script

    What am I missing? I have tried this script and others as well, but in all cases, only folders are made and the picture/s is not resized at all. Nothing happens. My guess is that I'm missing something but I don't know what it is.

  9. #9
    Join Date
    Nov 2004
    Location
    Southwest Missouri
    Beans
    217
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Batch resize nautilus script

    Quote Originally Posted by MockY View Post
    What am I missing? I have tried this script and others as well, but in all cases, only folders are made and the picture/s is not resized at all. Nothing happens. My guess is that I'm missing something but I don't know what it is.
    Make sure you have imagemagick installed. The convert command that you see in the script is part of the imagemagick package.

    You can install imagemagick easily using Synaptic or from the command line if you prefer using something like the following:

    apt-get install imagemagick

  10. #10
    Join Date
    Oct 2006
    Location
    Sacramento, California
    Beans
    529
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Batch resize nautilus script

    I made sure I had it installed before I posted, which is why I think this is weird. Any other ideas?

    EDIT: Just to be sure, I installed it using apt-get and it was successful. The reason why I didn't do that earlier was that Synaptic listed it as intalled.
    Last edited by MockY; October 26th, 2006 at 04:18 AM.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •