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>
1
  • Do you need to convert exactly this xml/html string? Commented Apr 21, 2011 at 9:52

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.