---------- Forwarded message ----------
From: William Henney <[email protected]>
Date: Wed, Jan 4, 2012 at 4:34 PM
Subject: Re: OutSRV [PyX-user] Bitmap resolution
To: [email protected]


Hi Bill

On Wed, Jan 4, 2012 at 9:20 AM, William Hudspeth <[email protected]> wrote:
> I am trying to insert JPEG images into my PDF document. I begin with a
> JPEG image, convert to Bitmap, and then insert the Bitmap... The
> resolution of the bitmap image is quite poor compared to the original
> jpeg. How can I improve the resolution???
>
> iom_logo='path/institute_horizontal.jpg' # 540 X 18 pixels
> i1=bitmap.jpegimage(iom_logo)
> c.insert(bitmap.bitmap(36, 765, i1, compressmode=None))

I generally load images using PIL. Something like this works for me
(and doesn't degrade the image as far as I can see):

-------------------------------------------------------------------------------------
import pyx
from PIL import Image
import sys

try:
   jpgfile = sys.argv[1]
   im = Image.open(jpgfile)
except:
   print "Usage: python pyx-jpg.py JPEGFILE"
   sys.exit()

nx, ny = im.size
bm = pyx.bitmap.bitmap(0, 0, im, width=nx*pyx.unit.x_pt,
height=ny*pyx.unit.x_pt)
c = pyx.canvas.canvas()
c.insert(bm)
c.writetofile("pyx-jpg-test.pdf")
----------------------------------------------------------------------------------------

Cheers

Will


--

  Dr William Henney, Centro de Radioastronomía y Astrofísica,
  Universidad Nacional Autónoma de México, Campus Morelia


-- 

  Dr William Henney, Centro de Radioastronomía y Astrofísica,
  Universidad Nacional Autónoma de México, Campus Morelia

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to