[reportlab-users] embedded png image quality

Jason Craig jason at iwocreative.com
Thu Jan 10 14:25:56 EST 2008


James Crone wrote:

> Hi,

>

> I`m embedding a PNG image (a map rendered from MapServer) into a pdf

> using reportlab with:

>

> import Image

> from reportlab.pdfgen import canvas

> from reportlab.lib.pagesizes import portrait,A4

>

> myImage = Image.open("C:/input_map_image.png")

> bgsMapCanvas =

> canvas.Canvas("C:/output_map_doc.pdf",pagesize=portrait(A4))

> bgsMapCanvas.setPageCompression(0)

> bgsMapCanvas.drawInlineImage(myImage,0,0,myImage.size)

> bgsMapCanvas.showPage()

> bgsMapCanvas.save()

>

>

> in the resulting pdf the embedded PNG image has been compressed

> resulting in a loss of image quality and a fuzzy map document :-( . Is

> it possible to prevent (PNG) images from being compressed when I add

> them to a document?

>

> Thanks in advance,

>

> James

>

I've noticed that in rendering a PDF, if am image is resized (i.e. if it
is drawn resized or if the PDF is not shown at actual size) then images
often look weird, but upon printing for example the images look fine.
Perhaps this is what you are experiencing?

--Jason

--
Regards,

Jason A. Craig
Senior Web Developer
Iwo Creative Design Group
106 Church St.
Logan UT, 84321

ph. 435.752.3503
web. www.iwocreative.com
email. jason at iwocreative.com



More information about the reportlab-users mailing list