LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 05-03-2007, 10:35 PM   #1
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Rep: Reputation: 31
Need to resize a lot of pictures -- software recommendation needed


My problem is, that when pictures come off of my 7MP digital camera, the filesize is around 3MB. I have been uploading these huge files to my online gallery, which is set to resize the pictures so they are a viewable size anyway.

So, I'd like to take, say, a directory at a time full of .jpg images and reduce their size down to 50% or so before uploading. Can you recommend a software program to do this?

(This is probably easy by writing a script to use ImageMagick or something, but I'm just not into writing it myself.)
 
Old 05-03-2007, 10:39 PM   #2
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
man convert
 
Old 05-03-2007, 10:44 PM   #3
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
I can't convert a whole directory at once, though....or am I missing something?
 
Old 05-03-2007, 10:54 PM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Code:
find . -maxdepth 1 -name "*.jpg" -exec convert -resize 50% {} smaller/{} \;
Scales pictures down 50% and puts them in the directory "smaller".
 
Old 05-03-2007, 10:54 PM   #5
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Try using a 'for' loop like this:
Code:
$ for i in `ls /path/to/picture/directory/*.jpg`; do convert $i -resize 50% /path/to/output/directory/$i; done
Note the use of backticks (`) as opposed to quote marks (').

Last edited by rkelsen; 05-03-2007 at 10:56 PM.
 
Old 05-03-2007, 11:02 PM   #6
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
Wow! I am in awe of your scripting skills!
 
Old 05-03-2007, 11:05 PM   #7
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
It worked, btw. Kudos to taylor and rkelsen!
 
Old 05-03-2007, 11:21 PM   #8
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally Posted by ErrorBound
Wow! I am in awe of your scripting skills!
It isn't as hard as you think. These were both (TV's response and mine) fairly simple examples.

Personally, I prefer a 'for loop' for this sort of thing:
Code:
for i in list-of-files; do command $i; done
You can use it for pretty much anything which requires a command to be run on a list of files. It is worth learning how to use, IMHO.
 
Old 05-03-2007, 11:26 PM   #9
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
Well, most of the programming experience I have is in C, so that's not very useful here. I do agree that shell scripting is extremely useful and worth learning though, I just haven't had the time for it yet.
 
Old 05-03-2007, 11:54 PM   #10
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally Posted by ErrorBound
Well, most of the programming experience I have is in C, so that's not very useful here.
C is Unix...
 
Old 05-04-2007, 12:01 AM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by rkelsen
It isn't as hard as you think. These were both (TV's response and mine) fairly simple examples.

Personally, I prefer a 'for loop' for this sort of thing
I do as well, however if the number of arguments gets to large, using a for loop will fail because the number of arguments will take up too much memory. In that case you can use "find" and "xargs":
Code:
find ./ -name "filepattern" -print0 | xargs -0 -L 1000 <command> <options>
Using print0 will use the null character to handle filenames with spaces in them.

Using a for loop, you also need to watch out for such filenames:
Code:
for i in <pattern>; do command "$i"; done
 
Old 05-04-2007, 12:30 AM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I have used convert to resize folders full of pictures---without any scripting.

I seem to recall that the "convert -resize" command can take a percentage. Now I can't find the syntax.

To do multiple files in one folder: "convert -resize <parameters> *"
 
Old 05-04-2007, 08:21 AM   #13
enine
Senior Member
 
Registered: Nov 2003
Distribution: Slackʍɐɹǝ
Posts: 1,486
Blog Entries: 4

Rep: Reputation: 282Reputation: 282Reputation: 282
What WM are you running? There is a simple download for KDE that lets you right click on one or more pictures and select a size. It simply calls imagemagick.
 
Old 05-06-2007, 12:53 PM   #14
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by enine
What WM are you running? There is a simple download for KDE that lets you right click on one or more pictures and select a size. It simply calls imagemagick.
I'm using both KDE and GNOME on different machines. The many suggestions above are working well though, and it simplifies my life just to be able to copy and paste the line into the terminal, which will work with any WM .
 
Old 05-06-2007, 12:56 PM   #15
ErrorBound
Member
 
Registered: Apr 2006
Posts: 280

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by rkelsen
Yes, C is very useful if you're into writing operating systems, but for a simple task like this, a bash one-liner will do quite well
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommendation needed: Motherboard & 64bit Processor rylan76 Linux - Hardware 1 09-13-2006 09:12 PM
ReiserFS resize help needed Godji Linux - General 9 01-08-2005 08:04 AM
mainboard/cpu recommendation needed hughgjohnson Linux - Hardware 2 05-13-2004 01:05 PM
help needed to get my digital camera pictures phunkymunky Linux - Hardware 6 03-23-2004 06:13 PM
What is the best software for viewing pictures or movies under console not in X? whepin Linux - General 1 03-28-2002 07:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 08:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration