[Tutor] command call in Windows for Image converting with
ImageMagick
Michael Just
mjust at sun11.ukl.uni-freiburg.de
Tue Apr 6 07:12:00 EDT 2004
command call in Windows for Image converting with ImageMagick
#############################################
Hello, python is quite new to me, so sorry for my stupid questions.
I have a image files which I want to have in the right dimensions for a
program to import.
SOME of the images (which are bigger than 600x400) need to be
transformed into smaller size.
In Photoshop I can script a batch job (a so called photoshop-"action")
which loads the imgages from directory "dir_in", resize the images a
save the imgages in a directory "dir_out"). This is doing well.
Unfortunately a photoshop-action can NOT DECIDE if the Image need to be
resized.
The man at the WinXP-computer where the program should run has no
admin-rights. So the program has to be an exe (which I want to build
with py2exe) or need no deeper installation (like ImageMagick).
So I thought this will be a good job for Python an ImageMagick.
Image Magick can analyse a image-file with the identify-program:
"identify <source-image-file-name>" which gives the output
"<source-image-file-name> JPEG 1017x282+0+0 ....."
Depending on that output the program should decide to resize with the
ImageMagick programm "convert" :
"convert -geometry 600x400 <source-image-file-name>
<target-image-file-name>".
#############################################################
#
#
Here are my questions:
1) How can I start the program "identify <image-file-name>"?
I got the <image-file-name> already with "os.listdir(os.curdir)"
2) How I fetch the output of "identify <image-file-name>"?
The call for "convert" will be the same as for 1) and 2).
3) How about error-handling, when a file could not be resized?
#
#
##################################################################
I wil be happy for any hint.
Thanks
Michael Just
mjust at ukl.uni-freiburg.de
University Hospital Freiburg
Germany
More information about the Tutor
mailing list