LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-22-2008, 09:49 AM   #1
control_guy
LQ Newbie
 
Registered: May 2008
Posts: 5

Rep: Reputation: 0
Resize (*.jpg) -> Rename -> Compress (xyz.tar) ?


Hello there

I am looking for a single line command that does the following:

1) Resize all *.jpg files in a given folder using convert function from imagemagick
2) Append the resized file names with _resized before the .jpg extension.
3) Create and pipe this data to a tar archive.

The following command resizes the images but I do not know how to proceed?

find . -name "*.jpg" -exec convert '{}' -resize 800x600 '{}' \;

Thank you very much
 
Old 05-22-2008, 10:33 AM   #2
control_guy
LQ Newbie
 
Registered: May 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Okay there is an improvement:

for i in `ls *.jpg`; do convert -resize 800x600 -quality 90 $i resized_$i; tar -rvf pics.tar conv_$i; done

But I still do not want the files to be created, and would rather forward the stream directly to tar. Any help??
 
Old 05-22-2008, 10:37 AM   #3
control_guy
LQ Newbie
 
Registered: May 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Okay here is my solution:

for i in `ls *.jpg`; do convert -resize 800x600 -quality 90 $i resized_$i; tar -rvf pics.tar resized_$i; rm resized_$i; done

Perhaps someone can do better?
 
Old 05-22-2008, 10:45 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by control_guy View Post
Okay there is an improvement:

for i in `ls *.jpg`; do convert -resize 800x600 -quality 90 $i resized_$i; tar -rvf pics.tar conv_$i; done

But I still do not want the files to be created, and would rather forward the stream directly to tar. Any help??
You don't need to use ls in the for loop:
Code:
for i in *.jpg; do 
   convert -resize 800x600 -quality 90 $i - | tar -rvf pics.tar;
done
The - in the convert command sends the output to standard output, and then it's piped into tar, whereupon tar reads in standard input instead of a bunch of file names.

edit: I'm a dunce. This doesn't work, but I don't know why. However, the part about not needing ls is true

Last edited by pwc101; 05-22-2008 at 10:51 AM.
 
Old 05-22-2008, 10:57 AM   #5
control_guy
LQ Newbie
 
Registered: May 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pwc101 View Post
This doesn't work, but I don't know why. However, the part about not needing ls is true
Yes I just tried but to no avail. But thanks for the ls tip.
 
Old 05-22-2008, 12:16 PM   #6
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 509

Rep: Reputation: 41
Quote:
Originally Posted by control_guy View Post
Okay there is an improvement:

for i in `ls *.jpg`; do convert -resize 800x600 -quality 90 $i resized_$i; tar -rvf pics.tar conv_$i; done

But I still do not want the files to be created, and would rather forward the stream directly to tar. Any help??
Yes, try "mogrify" - "convert" does the image manipulation and writes to a new file; mogrify manipulates the file itself.
 
Old 05-22-2008, 01:34 PM   #7
control_guy
LQ Newbie
 
Registered: May 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Su-Shee View Post
Yes, try "mogrify" - "convert" does the image manipulation and writes to a new file; mogrify manipulates the file itself.
Thanks but that does not solve the issue as I do not want to modify the original files.
 
  


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
Can you tar or rename / ? tongar Linux - Newbie 4 06-29-2007 12:19 PM
HELP! BASH - Convert filenames from dsc00***.jpg to *.jpg jimmybond01 Programming 9 05-08-2007 06:17 AM
How to resize and compress an MEPG for the web? calande Linux - Software 8 12-10-2006 03:11 PM
service xyz start instead of /etc/init.d/xyz start stefaandk Fedora 3 08-01-2006 08:00 PM
compress a directory using tar muskiediver Linux - General 4 07-18-2006 10:24 AM


All times are GMT -5. The time now is 05:54 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