[python-win32] JPEG to TIFF conversion
Larry Bates
larry.bates at websafe.com
Wed Dec 12 16:01:47 CET 2007
Larry Bates wrote:
> Manjeet Singh wrote:
>> Hi,
>> I am a new to the image conversion /compression concepts. I have few
>> thousands of images which were scanned in Uncompressed JPEG format(.Tiff
>> and .Jpeg). I am required to convert them to standard tiff files(CCIT
>> Group4). Is there any way to accomplish this in Python? I will be
>> thankful for the comments and suggestions. I am using Python 2.3.
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> http://mail.python.org/mailman/listinfo/python-win32
>
> PIL can convert to TIF, but can't save as compressed TIF. You can use an
> external program like tiffcp to compress them. I've done this before by writing
> the file, then calling os.system to run tiffcp.
>
> -Larry
Manjeet Singh Wadhwa wrote:
> Hi Larry,
> Thanks a lot for your information. I really appreciate it. Do you
know any site where I can get the code from to convert my file into Tiff using PIL .
>
>
> From: *Larry Bates* <larry.bates at websafe.com <mailto:larry.bates at websafe.com>>
> Date: Dec 11, 2007 9:47 AM
> Subject: Re: [python-win32] JPEG to TIFF conversion
> To: python-win32 at python.org <mailto:python-win32 at python.org>
>
>
> Manjeet Singh wrote:
> > Hi,
> > I am a new to the image conversion /compression concepts. I have few
> > thousands of images which were scanned in Uncompressed JPEG format(.Tiff
> > and .Jpeg). I am required to convert them to standard tiff files(CCIT
> > Group4). Is there any way to accomplish this in Python? I will be
> > thankful for the comments and suggestions. I am using Python 2.3.
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > python-win32 mailing list
> > python-win32 at python.org <mailto:python-win32 at python.org>
> > http://mail.python.org/mailman/listinfo/python-win32
<http://mail.python.org/mailman/listinfo/python-win32>
>
> PIL can convert to TIF, but can't save as compressed TIF. You can use an
> external program like tiffcp to compress them. I've done this before by writing
> the file, then calling os.system to run tiffcp.
>
> -Larry
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org <mailto:python-win32 at python.org>
> http://mail.python.org/mailman/listinfo/python-win32
>
>
>
>
>
> Warm Regards,
>
> *Manjeet Singh Wadhwa *
>
>
> FileNet BPM and Document Imaging Solutions
>
> *Extension 20716*
> *
> ------------------------------------------------------------------------
> *
>
> **********************************************************************
>
> ***** IMPORTANT INFORMATION *****
>
> This document should be read only by those persons to whom it is
>
> addressed and its content is not intended for use by any other
>
> persons. If you have received this message in error, please notify
>
> us immediately. Please also destroy and delete the message from
>
> your computer. Any unauthorised form of reproduction of this message
>
> is strictly prohibited.
>
>
>
> St George Bank Limited AFSL 240997, Advance Asset Management Limited
>
> AFSL 240902, St George Life Limited AFSL 240900, ASGARD Capital Management
Limited
>
> AFSL 240695 and Securitor Financial Group Limited AFSL 240687 is not liable for
>
> the proper and complete transmission of the information contained in
>
> this communication, nor for any delay in its receipt.
>
> **********************************************************************
>
>
>
Are all your images single pages and do you want to create single page TIF
files? If so it is quite easy:
from PIL import Image
#
# Assumptions: your .jpg files are 256 bit color (or grayscale)
#
im=Image.open(inputFile)
im2=im.convert('1') # convert to black and white
im2.save(outputFile, 'TIFF')
where:
inputFile is your .JPG file
outputFile is your .TIF file
then use:
tiffcp -c g4 outputfile.tif outputfileG5.tif
On the other hand, if you want to create multi-page tiffs it is quite a bit more
complicated. This creates uncompressed TIF file. I've used NetPBM
Hope this helps.
-Larry
More information about the python-win32
mailing list