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 532687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:25:52+00:00 2026-05-13T09:25:52+00:00

I want to specify a light source at a particular location in an image

  • 0

I want to specify a light source at a particular location in an image using Python.

PIL’s ImageEnhance module does provide a way to briten an image. but I want to have a control over light source placement to acheieve special effects. Does anyone know how to do this?

thank you!

  • 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-13T09:25:52+00:00Added an answer on May 13, 2026 at 9:25 am

    So, the bad news is that PIL can’t do that. I trhow a couple of ideas bellow, unfortunatelly none of which is straightforward.

    GIMP (GNU Image Manipulation Program) does have an awesome “ligthning effects” plug-in,

    GIMP is scriptable in Python, and it is possible to call teh plug-in paramtrically.
    The drawback is that your plug-in has to urn from within GIMP’s process. (So you’d either estart GIMP as a batch for a one time run, or have to design a server python plug-in that processes your images through the lightning effects plug-in)

    Other optionn I ma familiar with also involves off-process rendering would be use POVRay: render your image as the pigment-map for a 1x1x0.1 plane slab and then you can place “real” light-sources around.

    Another way is using OpenGL yourself – I browseddarond a bit, and maybe this “gloss” project can provide a way for you to use light sources without havign to descend into lowlevel opengl:
    http://www.tuxradar.com/gloss

    Or — “fake” it with a rectangular grid of black and white rectangles that you combine with your through color multiplication.
    This is the only way that would allow yiou to keep with PIL alone, but the “grid” lines are too visible, and I think that trying to smooth with blur would not cut it:

    def fake_light(image, tilesize=50):
        WIDTH, HEIGHT = i.size
        for x in xrange(0, WIDTH, tilesize):
            for y in xrange(0, HEIGHT, tilesize):
                br = int(255 * (1 - x / float(WIDTH) * y /float(HEIGHT)))
                tile = Image.new("RGBA", (tilesize, tilesize), (255,255,255,128))
                image.paste((br,br,br), (x, y, x + tilesize, y + tilesize), mask=tile)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using google api 15 on android emulator. I want to specify a country
solr sort,i want Specify a particular document at the first for example: Results :
I'm using wget for Windows and I want to specify a --post-data filter (and
I want to specify a signal handler in Perl, but using the number, not
I'm trying to insert an image but do not want to specify the x
I want to specify following hbm configuration using annotations: <id name=somePK column=&quot;somePK&quot; type=long> <generator
I am using Z3 4.1 C-API on linux. I want to specify a timeout
I want to specify a project to be opened when I launch Delphi(D2010). Is
I want to specify that either fieldname or freetext must always be present in
I want to specify the FileSystemWatcher to check the files in the system has

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.