1

I want to write a python program that converts given text into an image. There are tutorials for it online, but I want to curve the text over a circle.

Let's say I have the text "YOUR CURVED TEXT".

I want to draw this on an image and end up with something like following:

Final result after processing the image

I checked Pillow and OpenCV. I might be making a mistake but I don't think they have any functionality for curving the given text?

What would be the best way to do this?

Thanks in advance.

np3228
  • 39
  • 2
  • i think it's helpfull [click here](https://stackoverflow.com/a/44521963/9885352) – Sandeep Pareek Aug 30 '21 at 05:12
  • If you want vector files, you might want some kind of SVG solution. [SVGWrite](https://github.com/mozman/svgwrite) is not being actively developed, but it does have a [TextPath](https://svgwrite.readthedocs.io/en/latest/classes/text.html#textpath) method which will do what you want. [Inkscape](https://inkscape.org/) has an [extension system](https://inkscape-extensions-guide.readthedocs.io/en/latest/) which is based on Python. – bfris Aug 30 '21 at 15:53

1 Answers1

1

You can do something like that in ImageMagick using -distort arc 360.

convert -font Arial -pointsize 20 label:' Your Curved Text  Your Curved Text ' -virtual-pixel Background  -background white -distort Arc 360  -rotate -90  arc_circle_text.jpg

enter image description here

You can do that also in Python Wand, which uses ImageMagick as follows:

from wand.image import Image
from wand.font import Font
from wand.display import display

with Image() as img:
    img.background_color = 'white'
    img.font = Font('Arial', 20)
    img.read(filename='label: Your Curved Text  Your Curved Text ')
    img.virtual_pixel = 'white'
    # 360 degree arc, rotated -90 degrees
    img.distort('arc', (360,-90))
    img.save(filename='arc_text.png')
    img.format = 'png'
    display(img)

enter image description here

Thanks to Eric McConville for helping with the label: code.

fmw42
  • 37,738
  • 8
  • 47
  • 64