LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   resizing pictures with ImageMagick (https://www.linuxquestions.org/questions/linux-newbie-8/resizing-pictures-with-imagemagick-778143/)

Chenchu 12-26-2009 03:41 AM

resizing pictures with ImageMagick
 
hey everyone,
I found this app for resizing images. for some reason my camera took pictures in huge sizes (3000+ pixels) and I need to resize them to a normal size. so, I found this prog which does a great job with the 'convert' command.

i'm trying to make it convert all the pictures in one command.
its syntax is: convert -resize size pic.jpg newpic.jpg

I tried by this: ls > convert -resize 800 ..
but i've no idea how to specify its output. any ideas?

pixellany 12-26-2009 03:54 AM

Congratulations on discovering one of the major power tools!!

First, your camera has settings to control the output file size. Personally, I alway set it on the highest quality (largest file) and then downsize later.

From your command, it appears you are trying to do batch resizing. Try it your way, and I think it will simply assign its own filenames in some undesirable way. Much better to loop thru the folder---something like this:

<<untested>>
Code:

for pic in *; do
    convert -resize <size> $pic ${pic}new
done


bigrigdriver 12-26-2009 03:57 AM

A google search at www.google.com/linux (for Linux related searchs) turns up quite a bit about resizing with Imagemagick. Just search for: imagemagick howto resize

Chenchu 12-26-2009 04:01 AM

Thanks.. I think its working now. by saying batch you mean write a shell script right?
and can you please explain a lil bit how this small script works?
how does the var $pic gets its value?

thanks again, much appericiated.
saved me tons of time now editing them one by one :)

pixellany 12-26-2009 04:10 AM

The for loop assigns as value to the stated variable each time thru the loop.

General syntax:
for <variablename> in <expression>; do
<stuff to do>
done

<expression> can be as simple as the "*" (in this context meaning "everything I can see") or it can be the result of a command

Suppose you wanted only the files with names starting with "G". The loop would start with:

for <variablename> in $(ls|grep "^G")


For more on BASH scripting, head over to http://tldp.org and get the Bash Guide for Beginners

Chenchu 12-26-2009 04:17 AM

thanks alot pixellany for the explanation.

cola 12-26-2009 04:30 AM

Quote:

Originally Posted by Chenchu (Post 3805008)
hey everyone,
I found this app for resizing images. for some reason my camera took pictures in huge sizes (3000+ pixels) and I need to resize them to a normal size. so, I found this prog which does a great job with the 'convert' command.

i'm trying to make it convert all the pictures in one command.
its syntax is: convert -resize size pic.jpg newpic.jpg

I tried by this: ls > convert -resize 800 ..
but i've no idea how to specify its output. any ideas?

Got something here:
http://polishlinux.org/apps/graphics...h-imagemagick/


All times are GMT -5. The time now is 04:48 AM.