Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: HOWTO : 2 clicks resizing pictures with Nautilus

  1. #1
    Join Date
    Feb 2005
    Beans
    4

    Cool HOWTO : 2 clicks resizing pictures with Nautilus

    Just a small howto to let you resize a directory full of big pictures (typically from cameras) in a few click with zenity and nautilus.

    Put this script (you may also need to adapt to your needs) in your nautilus script directory ~/.gnome2/nautilus-scripts/ with the name of your choice (in this example Create_thumbs) :

    Code:
    #! /bin/sh
    
    # Dialog box to choose thumb's size
    SIZE=`zenity --list --title="Choose the thumbnail's size" --radiolist           --column="Check" --column="Size" "" "320x240" "" "640x480" "" "800x600" "" "1024x768"`
    
    if [ $SIZE -eq ""]; then    
    zenity --error --text="Size not defined by user.
    Please choose a size to use. "
    exit 1
    fi
    
    
    # How many files to make the progress bar
    PROGRESS=0
    NUMBER_OF_FILES=`find -iname "*.jpg" -maxdepth 1 | wc`
    let "INCREMENT=100/$NUMBER_OF_FILES"
    
    mkdir -p thumbnails
    
    # Creating thumbnails. Specific work on picture should be add there as convert's option
    (for i in *.jpg *.JPG; do
    echo "$PROGRESS";
    echo "# Resizing $i";
    convert -resize $SIZE  -bordercolor black -border 10x10 -quality 50 $i thumbnails/$i
    let "PROGRESS+=$INCREMENT"
    done
    ) | zenity  --progress --title "$Creating thumbnails..." --percentage=0
    1. Choose a directory and launch the script by right-clicking > scripts > Create_thumbs
    2. Choose the size your wish to use :


    3. See the script in action :


    4. A new directory appeared :


    As i said, this script should be adapt to your needs. Any improvments are welcome!

    Seb

  2. #2
    Join Date
    Nov 2004
    Location
    Anywhere
    Beans
    Hidden!

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    Good very good.

    thks for all your work.

  3. #3
    Join Date
    Dec 2004
    Location
    Finland
    Beans
    398

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    Thanks. I used to have a much simpler (and worse) script for this.

    I used an entry dialog for size input:
    Code:
    SIZE=`zenity --entry --title "Create thumbnails" --text "Biggest thumbnail dimension (pixels)"`
    Suggestions:
    - Add more image filetypes or just try to resize all files. As far as I know, convert doesn't crash trying to resize non-image files, they will just be skipped.
    - Close the progress window on completion with "--auto-close"

  4. #4
    Join Date
    Nov 2004
    Beans
    29

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    This is great. For you script-writing people I have a suggestion for something I needed a few times. I often want to email a picture to someone, but want to rescale it first. This script is most helpful in doing so. But it would be even more cool (IMO) to have, in addition, a script that does exactly what this script does, except that it should attach the files to an email instead of writing it to a new folder. Does anyone know how to do that?

  5. #5
    Join Date
    Mar 2005
    Beans
    6,040

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    this script could be combined with the email script found on this page to do what you want. there are other useful scripts on this page as well.

  6. #6
    Join Date
    Nov 2004
    Location
    Anywhere
    Beans
    Hidden!

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    Problem: When enter one of my directory's with jpeg files, i press the create thumbs script, i choose the size but then....

    The progress bar appears as full with the last jpeg bellow, i press ok, i enter the thumbs folder automatic generated....BUT NO Jpeg files inside!!!!! Odd

  7. #7
    Join Date
    Feb 2005
    Beans
    4

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    Quote Originally Posted by Sniffer
    Problem: When enter one of my directory's with jpeg files, i press the create thumbs script, i choose the size but then....

    The progress bar appears as full with the last jpeg bellow, i press ok, i enter the thumbs folder automatic generated....BUT NO Jpeg files inside!!!!! Odd
    Well, that's right. As it, the script only work with *.jpg and *.JPG. If your files are named *.jpeg, it wont work, sorry.

    I'll modify the script and follow above advises to improve it...

  8. #8
    Join Date
    Apr 2005
    Location
    Xpain
    Beans
    117
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    I've made some little changes on original script, just to avoid some bash scripting errors. Here's the code:

    Code:
    #! /bin/sh
    
    # Dialog box to choose thumb's size
    SIZE=`zenity --list --title="Choose the thumbnail's size" --radiolist --column="Check" --column="Size" "" "320x240" "" "640x480" "" "800x600" "" "1024x768"`
    
    if [ "${SIZE}" == "" ]; then    
    zenity --error --text="Size not defined by user.
    Please choose a size to use. "
    exit 1
    fi
    
    # How many files to make the progress bar
    PROGRESS=0
    NUMBER_OF_FILES=`find -iname "*.jpg" -maxdepth 1 | wc -l`
    let "INCREMENT=100/$NUMBER_OF_FILES"
    
    mkdir -p thumbnails
    
    # Creating thumbnails. Specific work on picture should be add there as convert's option
    (for i in *.jpg *.JPG; do
    echo "$PROGRESS";
    echo "# Resizing $i";
    convert -resize "${SIZE}"  -bordercolor black -border 10x10 -quality 50 "${i}" thumbnails/"${i}"
    let "PROGRESS+=$INCREMENT"
    done
    ) | zenity  --progress --title "$Creating thumbnails..." --percentage=0
    Thanks for the script and idea!!
    Last edited by infinito; May 19th, 2005 at 03:19 PM.

  9. #9
    Join Date
    Apr 2005
    Location
    Oslo, Norway
    Beans
    38
    Distro
    Gutsy Gibbon Testing

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    freeflight: Nice script, thanks for shareing.

    Infinito: Nice details, although it seems you missed a " after thumbnails/"${i} , and the entire last line.

    Regards,

  10. #10
    Join Date
    Nov 2004
    Location
    Anywhere
    Beans
    Hidden!

    Re: HOWTO : 2 clicks resizing pictures with Nautilus

    Quote Originally Posted by freeflight
    Well, that's right. As it, the script only work with *.jpg and *.JPG. If your files are named *.jpeg, it wont work, sorry.

    I'll modify the script and follow above advises to improve it...
    Nope, as you can see on the screenshot 1 my files are named as jpg or JPG, a launch the script, choose the size, press ok, the progress bar automatic go to the end...i press ok and nothing inside thumbnail folder!!!!!!!!!

    Just see the screenshots.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Screenshot1.png 
Views:	132 
Size:	453.4 KB 
ID:	1120   Click image for larger version. 

Name:	Screenshot2.png 
Views:	106 
Size:	437.0 KB 
ID:	1121   Click image for larger version. 

Name:	Screenshot3.png 
Views:	97 
Size:	422.7 KB 
ID:	1122   Click image for larger version. 

Name:	Screenshot4.png 
Views:	86 
Size:	62.9 KB 
ID:	1123  

Page 1 of 2 12 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
  •