In python you can do this:
Quote ( Posted 16th July 2008 by Brad Montgomery on some other site)
Django: Generating an Image with PIL
I've been reading through the Django Book, and in chapter 11 they talk about generating non-HTML content
(such as PDF files, Images, RSS/Atom Feeds). They mention using PIL to generate images, but they don't give an example.
So, I thought I'd post a simple example View that generates an image.
Code
def pil_image(request):
''' A View that Returns a PNG Image generated using PIL'''
import Image, ImageDraw
size = (100,50) # size of the image to create
im = Image.new('RGB', size) # create the image
draw = ImageDraw.Draw(im) # create a drawing object that is
# used to draw on the new image
red = (255,0,0) # color of our text
text_pos = (10,10) # top-left position of our text
text = "Hello World!" # text to draw
# Now, we'll do the drawing:
draw.text(text_pos, text, fill=red)
del draw # I'm done drawing so I don't need this anymore
# We need an HttpResponse object with the correct mimetype
response = HttpResponse(mimetype="image/png")
# now, we tell the image to save as a PNG to the
# provided file-like object
im.save(response, 'PNG')
return response # and we're done!
btw if you get some working code please share it with us so we all can use it also please!
This post was edited by implite on Jul 30 2016 03:24pm