LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-15-2003, 01:08 AM   #1
infidel
Member
 
Registered: Jun 2003
Location: Easley, SC, US
Distribution: Ubuntu 7.10, Mandrake 9.2
Posts: 91

Rep: Reputation: 15
Question Bulk image format conversions with a shell script?


Hello, all. I've been trying to come up with a way to perform bulk image format conversions. Essentially, I'd like to be able to save large quantities of JPEGs from my digital camera's memory card as TIFFs on my hard drive, without the JPEGs going through an intermediate save on the drive (and thus lossily re-compressing as they're saved). One-at-a-time conversions like this are no problem with existing image viewing/manipulation software ("Save As..."), but I typically have more then 70 images that I'd like to covert more or less at once. I don't seem to have a GUI program that will do it, and Mandrake's wacky directory structure prevents me from successfully compiling & installing anything new. It occurred to me today that since I only want to do one thing, a shell script might be a good way to do it. I have some novice (read "absolute beginner") scripting skills, but working with image formats is beyond me at the moment.

In brief, let's say that I have a bunch of files called *.jpg on /mnt/removable. I want all of them to end up as *.tif files in /home/marv/images, and I'd like to do it from the command line.

First, I assume that there have to be particular libraries available for the image format operations; can anyone tell me what they are and how to determine whether or not they're present on my system? Secondly, if the tools I need are there, would scripting this operation be a fairly simple process? If what I'm asking for here is essentially for someone to write me a program, please accept my apologies. But if it's not terribly complicated, I would greatly appreciate a gentle push in the right direction. I'm not even sure that a shell script would be the best way to do the job; but the concept, at least, seems to make sense to me. Either way, some information would be greatly appreciated. Thanks very much in advance.
 
Old 11-15-2003, 01:25 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
The ImageMagick suite of programs
has the tool you might be looking for.

Try a
man convert
in a terminal and see whether it suites you!

Cheers,
Tink
 
Old 11-15-2003, 06:50 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
And, working for you?


Cheers,
Tink
 
Old 11-16-2003, 12:41 AM   #4
infidel
Member
 
Registered: Jun 2003
Location: Easley, SC, US
Distribution: Ubuntu 7.10, Mandrake 9.2
Posts: 91

Original Poster
Rep: Reputation: 15
You see, I should've known before I even opened my mouth-- this is Linux we're talking about; and if there's something worth doing, chances are that somebody created the tools to do it a long time ago.

ImageMagick is a fascinating set of tools, and it appears as though it will do exactly what I want (and near-infinitely more)-- if I can determine how to convert a bunch of files in one go. ImageMagick's 'convert' says it will convert an image or a sequence of images, but figuring out the command syntax for the sequence business has been the tricky part. I haven't been able to find any clear documentation on it. Single-file format conversions, yes; batch jobs, no. I've read the man page, visited the official web site, Googled it, and so on with no clear answer.

Am I correct in guessing that it's reasonable that there sould be some kind of "wildcard" arrangement or similar, where I specify that I want all .jpg files in one directory to end up as .tif files in another, without having to enter filename after filename in the command line? I'm sorry if I'm missing something completely obvious, but I can't seem to figure it out.

Thanks again...
 
Old 11-16-2003, 08:20 PM   #5
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
I've used the convert utility from ImageMagick several times to do mass conversion. The last time was for a group that went from gif to png. My quick conversion was done with:

for FILE in *.gif
do
convert $FILE png:`echo $FILE | sed 's/.gif/.png/g'`
done

You'll probably want to do a small batch at first and check the quality of them before you get to far along. There are several convert options that will affect output quality.

Last edited by stickman; 11-16-2003 at 08:22 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Batch File for format? Bulk Formatting Beebe Solaris / OpenSolaris 2 04-12-2005 06:07 AM
Bulk Image Maniulation doctorwebbox Linux - Software 1 10-20-2004 04:58 AM
Bulk change image format apokryphos Linux - General 11 09-06-2004 05:17 PM
Shell script ip address format check. rooch84 Linux - Software 6 08-18-2004 10:14 AM
Making shell script a part of linux image mayureshchitale Linux - Newbie 1 07-06-2004 02:00 AM


All times are GMT -5. The time now is 12:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration