~ubuntu-branches/ubuntu/trusty/python-imaging/trusty

« back to all changes in this revision

Viewing changes to PIL/PdfImagePlugin.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-11-20 19:22:59 UTC
  • mfrom: (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091120192259-cmnfui5tv2jtq4xu
Tags: 1.1.7-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
# The Python Imaging Library.
3
 
# $Id: PdfImagePlugin.py 2438 2005-05-25 21:09:48Z Fredrik $
 
3
# $Id$
4
4
#
5
5
# PDF (Acrobat) file handling
6
6
#
52
52
# (Internal) Image save plugin for the PDF format.
53
53
 
54
54
def _save(im, fp, filename):
 
55
    resolution = im.encoderinfo.get("resolution", 72.0)
55
56
 
56
57
    #
57
58
    # make sure image data is available
148
149
    xref[3] = fp.tell()
149
150
    _obj(fp, 3, Type = "/XObject",
150
151
                Subtype = "/Image",
151
 
                Width = width,
152
 
                Height = height,
 
152
                Width = width, # * 72.0 / resolution,
 
153
                Height = height, # * 72.0 / resolution,
153
154
                Length = len(op.getvalue()),
154
155
                Filter = filter,
155
156
                BitsPerComponent = bits,
171
172
             "/Resources <<\n/ProcSet [ /PDF %s ]\n"\
172
173
             "/XObject << /image 3 0 R >>\n>>\n"\
173
174
             "/MediaBox [ 0 0 %d %d ]\n/Contents 5 0 R\n>>\n" %\
174
 
             (procset, width, height))
 
175
             (procset, int(width * 72.0 /resolution) , int(height * 72.0 / resolution)))
175
176
    _endobj(fp)
176
177
 
177
178
    #
179
180
 
180
181
    op = StringIO.StringIO()
181
182
 
182
 
    op.write("q %d 0 0 %d 0 0 cm /image Do Q\n" % (width, height))
 
183
    op.write("q %d 0 0 %d 0 0 cm /image Do Q\n" % (int(width * 72.0 / resolution), int(height * 72.0 / resolution)))
183
184
 
184
185
    xref[5] = fp.tell()
185
186
    _obj(fp, 5, Length = len(op.getvalue()))