3

I have following xml/html string and want to convert it to jpg can any one know how could I achieve this?

<Text index="1" text="Hello Rizwan Ullah&#xD;" rotation="0" offsetX="182.7" offsetY="96.75" backgroundColor="10066329" backgroundAlpha="0.4" margin="0">
<![CDATA[<TEXTFORMAT LEADING="2">
<P ALIGN="LEFT">
<FONT FACE="arialfontB" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">
<B>H</B>
<FONT FACE="defaultFont">ello
<FONT SIZE="12"> 
<FONT SIZE="32">Rizwan</FONT> 
<FONT SIZE="24" COLOR="#FF0000">Ullah
<FONT SIZE="12"></FONT>
</FONT>
</FONT>
</FONT>
</FONT>
</P>
</TEXTFORMAT>]]>
<Transform x="182.7" y="96.75">a=1.347221851348877, b=0, c=0, d=1.347221851348877, tx=182.7, ty=96.75</Transform>
</Text>
WhiteFang34
  • 70,765
  • 18
  • 106
  • 111
Curiologix
  • 83
  • 1
  • 7

1 Answers1

1

Python Imaging Library (PIL) can render text to an image:

Example from a pre-existing question:

from PIL import Image
import ImageFont, ImageDraw

image = Image.new("RGBA", (288,432), (255,255,255))
usr_font = ImageFont.truetype("resources/HelveticaNeueLight.ttf", 25)
d_usr = ImageDraw.Draw(image)
d_usr = d_usr.text((105,280), "MYTEXT",(0,0,0), font=usr_font)

See also:

http://www.pythonware.com/products/pil/

Python Imaging Library - Text rendering

Community
  • 1
  • 1
elliot42
  • 3,694
  • 3
  • 26
  • 27