G
Gelonida N
Hi,
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.
# ------------------------code starts here
import Image
import ImageFont
import ImageDraw
# Here I don't know how to get the same font file
# for all platforms
# Perhaps there is a tiny trick that I overlooked.
font_file = get_font_file_name()
# Is truetype a good choice for portable fonts?
font = ImageFont.truetype(font_file, 20)
img = Image.new("RGB", (800, 600), "#FFFFFF")
draw = ImageDraw.Draw(image)
draw.text( (100, 100), font=font, fill="#00FF00")
# ---------------------------- end of code
I could also install any other library (matplotlib??)
if it were capable of creating consistent images
independent on the platform.
Thanks in advance for any suggestions.
I'd like create a small image file (e.g. .png)From within a django application
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.
# ------------------------code starts here
import Image
import ImageFont
import ImageDraw
# Here I don't know how to get the same font file
# for all platforms
# Perhaps there is a tiny trick that I overlooked.
font_file = get_font_file_name()
# Is truetype a good choice for portable fonts?
font = ImageFont.truetype(font_file, 20)
img = Image.new("RGB", (800, 600), "#FFFFFF")
draw = ImageDraw.Draw(image)
draw.text( (100, 100), font=font, fill="#00FF00")
# ---------------------------- end of code
I could also install any other library (matplotlib??)
if it were capable of creating consistent images
independent on the platform.
Thanks in advance for any suggestions.