Coordinates-based text display upon an image with Django's template system -
i trying update excel-map data fetched django , display on page linked admin.
the excel-"map" :
using xlrd & cie libs i'm working on fetching / updating data part fellow dev told me have used image instead.
my question : how such thing ? displaying copy of above spreadsheet , using row-based coordinates write data want ? (text data)
do guys know way work coordinate-based text display in django's templates ?
thanks can give me !
i ended using pil library. quite easy , summarized following code :
from pil import image pil import imagedraw pil import imagefont im = image.open('path/to/map.png') font = imagefont.truetype('/usr/share/fonts/dejavu/dejavusans.ttf', 7) draw = imagedraw.draw(im) draw.text((x, y), sentence, font=font, fill='black') response = httpresponse(mimetype='image/png') im.save(response, 'png') return response
logic behind x , y irrelevant here, bear in mind start quite illogically on upper left corner of image , go there right , bottom positive numbers.
Comments
Post a Comment