Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10794

Text to image with same results on any platform

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'suggestions.': 0.07; 'python': 0.08; 'pixel': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:image': 0.09; 'library': 0.15; '(100,': 0.16; '(assuming': 0.16; 'pil': 0.16; 'advance': 0.18; 'linux': 0.18; 'starts': 0.19; 'appropriate': 0.20; 'wondered': 0.23; 'versions': 0.23; 'code': 0.24; 'creating': 0.24; 'libraries': 0.25; '(e.g.': 0.25; 'import': 0.29; 'yield': 0.29; 'django': 0.29; 'subject:same': 0.30; 'thanks': 0.31; 'hi,': 0.31; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'there': 0.34; 'identical': 0.35; 'install': 0.36; 'file': 0.36; 'some': 0.37; 'platforms': 0.37; 'but': 0.37; 'could': 0.37; 'getting': 0.38; 'received:org': 0.38; 'platform': 0.38; 'perhaps': 0.39; 'should': 0.39; 'header :Mime-Version:1': 0.39; 'subject:with': 0.39; 'under': 0.39; 'to:addr:python.org': 0.39; "i'd": 0.40; 'here': 0.66; 'tiny': 0.68; 'subject:Text': 0.77; 'difficulties': 0.84; 'img': 0.84; 'subject:any': 0.84; 'truetype': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Gelonida N <gelonida@gmail.com>
Subject Text to image with same results on any platform
Date Wed, 03 Aug 2011 11:40:48 +0200
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host unicorn.dungeon.de
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 ""
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1827.1312364463.1164.python-list@python.org> (permalink)
Lines 51
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312364463 news.xs4all.nl 23836 [2001:888:2000:d::a6]:59452
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10794

Show key headers only | View raw


Hi,


>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.





# ------------------------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.






Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Text to image with same results on any platform Gelonida N <gelonida@gmail.com> - 2011-08-03 11:40 +0200

csiph-web