1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to put correct Marathi/Hindi text on Image using PIL in python

Discussão em 'Python' iniciado por Stack, Novembro 23, 2025.

  1. Stack

    Stack Membro Participativo

    import os
    from PIL import *
    import numpy as np
    import pandas as pd
    from PIL import Image
    from PIL import ImageFont
    from PIL import ImageDraw

    # background png stored in list
    os.chdir('D:\\My Image Processing\\Image Design\\IMAGE PROCESSING\\back\\BLACK FONT BG')
    back = os.listdir()

    for b in range(len(back)):
    #background
    b1 = Image.open(f"D:\\My Image Processing\\Image Design\\IMAGE PROCESSING\\back\\BLACK FONT BG\\{back}")

    # text
    draw = ImageDraw.Draw(b1)

    # Font
    font33 = ImageFont.truetype("D:\\My Image Processing\\Image Design\\IMAGE PROCESSING\\fonts\\Poppins-Medium.ttf", 80)

    x = "हार पत्करण माझ ध्येय नाही कारण मी बनलोय जिंकण्यासाठी."
    draw.text((310,220), values.center(1), x,font=font33, align='center', stroke_width=1, stroke_fill=(0,0,0))


    b1.save(f'D:\\My Image Processing\\Image Design\\IMAGE PROCESSING\\output\\BLACK OUTPUT MARATHI\\img.png')


    output:

    [​IMG]

    I am trying to put text on the image I was able to put English text on the image but when I tried to put text of other language such as hindi and marathi it is showing me various kind of errors such as wrong spelling & wrong syntax of that language... I tried various fonts and size but unable to over come this problem... So I ask for your help to overcome this problem.

    Continue reading...

Compartilhe esta Página