On Sunday 20 January 2002 14:07, Carlos Lorenzo Matés wrote: <snip>
can anybody here point me in a direction where to start looking for commandline tools to manipulate jpg-images on the commandline?
You need to have installed the convert command from the imagemagick package.
put this into a file called jpgresize.sh and make a subdirectory named sized on the directory where the images lies
#!/bin/sh # Script to resize jpg images # it converts all files into the directory # the new files will be in a directory called sized list=`ls *jpg` for i in $list do file=${i##*/} base=${file%%.*} convert -geometry x150 $base.jpg sized/$base.jpg done echo Done
What I want to do is this: I need to resize large numbers of jpg-files using a script or sth. It should take the longest side of an image and resize it to a given (pixel) length while resizing the other side accordingly at the same rate...
this script resizes based on the height it makes the new images 150 pixels height and resize the width mantaining the image aspect, if you want another size change the x150 by the number you want, if you want to base on the width xhange the x150 by only the new width (ie 120) <snip>
thanx alot, this is a good place to start from... I've been digging through manpages and stuff for a while now, trying to find a way to get the width and height from an image to compare those to determine which convert to call... this is what I want to accomplish: #!/bin/sh # mkdir resized for f in *.jpg do if ["height of image">"width of image"] then convert -geometry x400 $f resized/$f else convert -geometry 600 $f resized/$f fi done the only command I found to get height and width of an image is this: "rdjpgcom -verbose img_0002.jpg" using it together with awk: "rdjpgcom -verbose img_0002.jpg | awk '{print $4 $6}'" gives me this output: 1200w 1600h, Can I further strip this output down to integers that I could put into variables for comparison? Or is there an easier way to get integer values? thanx for any advice, Johannes -- Powered by SuSE 7.3 - KDE 2.2.1 - KMail 1.3.1 Version Info: Linux 2.4.10-4GB