[Tutor] Converting to PDF

"Héctor Villafuerte D." hec.villafuerte at telgua.com.gt
Wed Jan 7 21:29:06 EST 2004


Hi all,
I'm trying to generate PDFs with this little script:

-----SCRIPT-------------------------
import fileinput, os, Image

def get_calls(dir, file):
    im = Image.open(dir + file)
    im.save(dir + '_' + file, 'PDF')

if __name__ == '__main__':
    dir = 'c:\\tmp\\scan\\'
    for x in os.listdir(dir):
        if x.split('.')[1] == 'jpg':
            print x
            get_calls(dir, x)
-----------------------------------

But get this error:
-----ERROR-------------------------
Traceback (most recent call last):
  File "e:\src\python\convert_jpeg.py", line 22, in ?
    get_calls(dir, x)
  File "e:\src\python\convert_jpeg.py", line 6, in get_calls
    im.save(dir + '_' + file, 'PDF')
  File "C:\Python23\Lib\site-packages\PIL\Image.py", line 1145, in save
    SAVE[string.upper(format)](self, fp, filename)
  File "C:\Python23\Lib\site-packages\PIL\PdfImagePlugin.py", line 120, 
in _save
    raise ValueError, "unsupported PDF filter"
ValueError: unsupported PDF filter
-----------------------------------

Any ideas or suggestions of how to generate PDF from JPEG?
Thanks in advance.
Hector




More information about the Tutor mailing list