Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Ubuntu 9.10 is out!!!

When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu.

The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely.

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old May 16th, 2005   #1
freeflight
First Cup of Ubuntu
 
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
freeflight is offline   Reply With Quote
Old May 16th, 2005   #2
Sniffer
Gee! These Aren't Roasted!
 
Sniffer's Avatar
 
Join Date: Nov 2004
Location: Anywhere
My beans are hidden!
Re: HOWTO : 2 clicks resizing pictures with Nautilus

Good very good.

thks for all your work.
Sniffer is offline   Reply With Quote
Old May 16th, 2005   #3
ow50
Quad Shot of Ubuntu
 
ow50's Avatar
 
Join Date: Dec 2004
Location: Finland
Beans: 400
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"
ow50 is offline   Reply With Quote
Old May 16th, 2005   #4
risager
5 Cups of Ubuntu
 
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?
risager is offline   Reply With Quote
Old May 16th, 2005   #5
23meg
Ubuntu QA Team
 
Join Date: Mar 2005
Location: İstanbul
Beans: 5,798
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.
23meg is offline   Reply With Quote
Old May 16th, 2005   #6
Sniffer
Gee! These Aren't Roasted!
 
Sniffer's Avatar
 
Join Date: Nov 2004
Location: Anywhere
My beans are 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
Sniffer is offline   Reply With Quote
Old May 16th, 2005   #7
freeflight
First Cup of Ubuntu
 
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...
freeflight is offline   Reply With Quote
Old May 18th, 2005   #8
infinito
A Carafe of Ubuntu
 
infinito's Avatar
 
Join Date: Apr 2005
Location: Xpain
Beans: 116
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 10:19 AM..
infinito is offline   Reply With Quote
Old May 18th, 2005   #9
GeirG
Ubuntu Espresso Roast
 
GeirG's Avatar
 
Join Date: Apr 2005
Location: Oslo, Norway
Beans: 39
Gutsy Gibbon Testing
Send a message via MSN to GeirG
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,
__________________
Regards,
GeirG

Registered Linux user #346865
GeirG is offline   Reply With Quote
Old May 18th, 2005   #10
Sniffer
Gee! These Aren't Roasted!
 
Sniffer's Avatar
 
Join Date: Nov 2004
Location: Anywhere
My beans are 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 Images
File Type: png Screenshot1.png (453.4 KB, 92 views)
File Type: png Screenshot2.png (437.0 KB, 70 views)
File Type: png Screenshot3.png (422.7 KB, 53 views)
File Type: png Screenshot4.png (62.9 KB, 44 views)
Sniffer is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:05 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry