On 08/04/2011 12:32 PM, Thomas Jollans wrote: > On 04/08/11 12:04, Gelonida N wrote: Thanks for your answer.
>> >From within a django application >> I'd like create a small image file (e.g. .png) >> which just contains some text. >> >> I wondered what library would be appropriate and would yield the same >> result independent of the OS (assuming the versions of the python >> libraries are the same) >> Images should be pixel identical independent on the platform on which >> the image is created. >> >> I made some attempts with PIL (Image / ImageFont / ImageDraw), >> but have difficulties getting the same font under Linux and windows. > > Perhaps PIL uses a different font rendering library on each platform? > You could try to get around this by using > http://code.google.com/p/freetype-py/ directly. It's also possible that > different hinting settings on the different systems are playing a role > somehow, somewhere. Perhaps you can tell freetype precisely what to do, > I'm not sure. The reason why I want the images to look identical is very simple. Though the final web server will run on a linux server, I use sometimes windows for development or as test server. For automated tests I would have liked pixel identical images. this allows calculating the md5sum of images to know whether a regression in the image layout occured. Well I can live without it. The second (more import issue) is, that the images should look the same whether created on a Windows or Linux host. I didn't know that PIL delegated font rendering to the underlying OS, but thought it contains its own rendering. Here the problem is not if a few pixels are different, but currently I even don't know how to choose a font, and make sure it exists on both platforms. I also don't know how I can write portable python code, that will find a given font on windows and on linux independent of the exact font location. > > If you want exactly the same bitmap on different platforms, you could > just scrap truetype alltogether, and use bitmaps directly, individually > taking the characters you need from a resource file. (you know, one > bitmap with all the characters at known coordinates - or a load of small > bitmaps) A resource file or a bitmapped font packaged with my application might be a solution. I just had to learn where to get one from or how to create one without any copyright issues > > Why do you need the images to be identical to the pixel anyway? Surely, > if it's about comparing the text, you would just compare the strings? > And if it's only for displaying the text, then why bother with details > like that as long as it looks good? I hope I clarified a little what I was looking for. It's not necessarily pixel true, but it should not be too visible whether the image was rendered on a windows or linux PC -- http://mail.python.org/mailman/listinfo/python-list