Hello Manuel,
On 08.08.06, Manuel Gomes wrote:
> Hello list, I've just started attempting to use pyx, and am faced with
> an awkward situation when trying to feed it a JPG. A minimalistic example:
>
> import Image
> from pyx import *
>
> f="myfile.jpg"
> im=Image.open(f)
> w,h=im.size
> print w,h #gives the correct values for width and height, im.info
> has no DPI values in it.
This is not really correct. im.size gives you the number of pixels in
x- and y-direction. It does not provide the (physical) extension of
the picture. Together with the dpi-information, this extension could
be calculated.
> c=canvas.canvas()
> i = bitmap.jpegimage(f)
> c.insert(bitmap.bitmap(0,0,i,compressmode=None)) #error occurs here
> c.writePDFfile("output")
As there is no width and no dpi information in the jpeg-file, PyX does
not know how large the bitmap should be. The width and height is a
necessary information.
> And sure enough - as noted in the snippet above, the image has no DPI
> data. Much the same happens when trying to feed it the *im* image by
> the method documented in the examples.
>
> I DO, however, have both width and height for it... if only I could feed
> them to pyx somehow. Am I missing a different constructor or some such ?
> Or, in a slightly bassackwards manner, is there a way to inject DPI
> information into the image with the PIL? Basically any workaround will do.
Everything is alright, if you say, how large you want your picture
(e.g. 10cm in user-lengths):
c.insert(bitmap.bitmap(0, 0, i, compressmode=None, width=10))
Michael.
--
"A mathematician is a device for turning coffee into theorems"
Paul Erdös.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user