manipulating jpg-imgs from the command line..
Hi, can anybody here point me in a direction where to start looking for commandline tools to manipulate jpg-images on the commandline? 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... thanx in advance for any suggestions, Johannes -- Powered by SuSE 7.3 - KDE 2.2.1 - KMail 1.3.1 Version Info: Linux 2.4.10-4GB
On Sat, 2002-01-19 at 09:06, Johannes Liedtke wrote:
Hi,
can anybody here point me in a direction where to start looking for commandline tools to manipulate jpg-images on the commandline?
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...
thanx in advance for any suggestions, Johannes
-- Powered by SuSE 7.3 - KDE 2.2.1 - KMail 1.3.1 Version Info: Linux 2.4.10-4GB
Johannes, Check out the "convert" command line utility from the ImageMagick RPM. You can use a bash script to feed the images to it and do whatever you want with them. Good luck, Steven
Hello. El Sábado 19 Enero 2002 15:06, Johannes Liedtke escribió:
Hi,
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 commandfrom 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) this script is also valid for changing the image format, you only need to change the destination name to $base.gif to obtain the images in .gif format. sell also man convert to obtains more information
thanx in advance for any suggestions, Johannes
-- Greetings Carlos Lorenzo Mates
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
On Sunday 20 January 2002 18:52, Anders Johansson wrote:
On Sunday 20 January 2002 18.25, Johannes Liedtke wrote:
"rdjpgcom -verbose img_0002.jpg"
ImageMagick is your friend
identify -format "%w %h" img_0002.jpg
There are many ways to play around with this.
I figure... but where do I find all the tools that ImageMagick supplies? I couldn't find sth like an overview for it... Johannes -- Powered by SuSE 7.3 - KDE 2.2.1 - KMail 1.3.1 Version Info: Linux 2.4.10-4GB
On Sunday 20 January 2002 19.38, Johannes Liedtke wrote:
I figure... but where do I find all the tools that ImageMagick supplies? I couldn't find sth like an overview for it...
When I have an image related problem I always start with the assumption that ImageMagick can do it, and then set about trying to figure out how :) /usr/share/doc/packages/ImageMagick/ImageMagick.html is a good starting point. The various man pages are also fairly good. //Anders
On Sunday 20 January 2002 18:52, Anders Johansson wrote:
On Sunday 20 January 2002 18.25, Johannes Liedtke wrote:
"rdjpgcom -verbose img_0002.jpg"
ImageMagick is your friend
identify -format "%w %h" img_0002.jpg
There are many ways to play around with this.
but "identify" seems to be returning strings, so I'm again unable to compare height and width of the images... :( I guess I need sth like the java parseInt()-function... Johannes -- Powered by SuSE 7.3 - KDE 2.2.1 - KMail 1.3.1 Version Info: Linux 2.4.10-4GB
On Sunday 20 January 2002 20.47, Johannes Liedtke wrote:
On Sunday 20 January 2002 18:52, Anders Johansson wrote:
On Sunday 20 January 2002 18.25, Johannes Liedtke wrote:
"rdjpgcom -verbose img_0002.jpg"
ImageMagick is your friend
identify -format "%w %h" img_0002.jpg
There are many ways to play around with this.
but "identify" seems to be returning strings, so I'm again unable to compare height and width of the images... :(
I guess I need sth like the java parseInt()-function...
Not at all. bash can handle it #!/bin/bash width=`identify -format "%w" test.jpg` height=`identify -format "%h" test.jpg` if [ $width -gt $height ] then echo "width greater than height" fi regards Anders
Johannes Liedtke
identify -format "%w %h" img_0002.jpg
There are many ways to play around with this.
but "identify" seems to be returning strings, so I'm again unable to compare height and width of the images... :(
There are many ways how to read several strings in bash. See the following two examples: #!/bin/bash identify -format "%w %h" img_0002.jpg \ | { read width height echo "width = $width, height = $height" } #!/bin/bash set $(identify -format "%w %h" img_0002.jpg) echo "width = $1, height = $2" -- Alexandr.Malusek@imv.liu.se
participants (5)
-
Alexandr Malusek
-
Anders Johansson
-
Carlos Lorenzo Matés
-
Johannes Liedtke
-
Steven Hatfield