LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Resize (*.jpg) -> Rename -> Compress (xyz.tar) ? (https://www.linuxquestions.org/questions/linux-newbie-8/resize-%2A-jpg-rename-compress-xyz-tar-644038/)

control_guy 05-22-2008 09:49 AM

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

control_guy 05-22-2008 10:33 AM

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??

control_guy 05-22-2008 10:37 AM

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?

pwc101 05-22-2008 10:45 AM

Quote:

Originally Posted by control_guy (Post 3161468)
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 :D

control_guy 05-22-2008 10:57 AM

Quote:

Originally Posted by pwc101 (Post 3161477)
This doesn't work, but I don't know why. However, the part about not needing ls is true :D

Yes I just tried but to no avail. But thanks for the ls tip.

Su-Shee 05-22-2008 12:16 PM

Quote:

Originally Posted by control_guy (Post 3161468)
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.

control_guy 05-22-2008 01:34 PM

Quote:

Originally Posted by Su-Shee (Post 3161536)
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.


All times are GMT -5. The time now is 09:16 AM.