[Image-SIG] FW: Converting TIFF to JPEG

Moodie, Craig CA Moodie.Craig.CA@bhp.com
Wed, 20 Sep 2000 09:44:33 +1100


> Hi ,
>  I managed to sus out the The _imaging C module is not installed problem by adding - import Tkinter.--got this apparent fix from the Image-SIG archives.
> 
> # myconvert_jpeg.py
> import os, sys
> import Tkinter
> import Image
> 
> for infile in sys.argv[1:]:
> 	outfile=os.path.splitext(infile)[0]+".jpg"
> 	im=Image.open(infile)
> 	# print infile,im.format,"%dx%d" % im.size,im.mode
> 	im.save(outfile,"JPEG")
> 
>  However on running this I got the following raise IOError
> 
> C:\Program Files\Python\Scripts>python myconvert_jpeg.py image12194.tif
> Traceback (innermost last):
>   File "myconvert_jpeg.py", line 17, in ?
>     im.save(outfile,"JPEG")
>   File "C:\PROGRAM FILES\PYTHON\PIL\Image.py", line 666, in save
>     SAVE[string.upper(format)](self, fp, filename)
>   File "C:\PROGRAM FILES\PYTHON\PIL\JpegImagePlugin.py", line 298, in _save
>     raise IOError, "cannot write mode %s as JPEG" % im.mode
> IOError: cannot write mode P as JPEG
> 
> Previously I ran the script with the print line active and got the image format detail below.
> 
> c:\progra~1\python\Scripts\image12194.tif TIFF 853x603 P
> 
> Can anybody inform me as to what I should do next to enable a conversion.
> Incidently the TIFF image was created using the DISLIN (Max Planck Institute) graphics libraries for Windows----RTIFF function.
>                                 Craig
> 
> 
> 
EOM 

NOTICE - This message contains information intended only for the use of the addressee named above.  It may also be confidential and/or privileged.  If you are not the intended recipient of this message you are hereby notified that you must not disseminate, copy or take any action in reliance on it.  If you have received this message in error please notify postmaster@bhp.com.