Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6984047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:29:58+00:00 2026-05-27T18:29:58+00:00

I have the following PIL code to print text in an image import os,

  • 0

I have the following PIL code to print text in an image

import os, sys
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw

img = Image.open("one.jpg")
draw = ImageDraw.Draw(img)    
font = ImageFont.truetype("/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf",27)
draw.text((100, 100), "test test test", font=font)    
img.save("out.jpg")

This works on one.jpg file. However on another test file called two.jpg, it doesn’t print anything. From what I see, the only difference between two documents is the lower resolution on two.jpg. The file one.jpg is 200×200 dpi, two.jpg is 60×60 dpi.

How can I get draw.text to work in lower res?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:29:58+00:00Added an answer on May 27, 2026 at 6:29 pm

    You need to specify a color for the text:

    import os
    import sys
    import ImageFont
    import Image
    import ImageDraw
    
    img = Image.open("two.jpg")
    draw = ImageDraw.Draw(img)    
    font = ImageFont.truetype("/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf",27)
    draw.text((100, 100), "test test test", font=font, fill = 'blue')    
    img.save("out.jpg")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: print(img.size) print(10 * img.size) This will print: (70, 70)
I have following code for an autocomplete box, I'm adding an image for choice
Have following validation for year value from text input: if (!year.match(new RegExp('\\d{4}'))){ ... }
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following text in a file 23456789 When I tried to replace the
I have following Code Block Which I tried to optimize in the Optimized section
Have following listener for keyboard ArrowDown event(it's key code is 40 ): window.onload =
The following code takes an image after it gets saved and makes a thumbnail
Have following code: public interface ITest { string St1 { get; } } public
I have following method in my Borland C++ code, static bool UploadBitstream(void) { //Some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.