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

Per the Google Page Speed recommendations, I want to Specify image dimensions to Optimize
I am using Mvvm-Light and have been ignoring how binding in XAML really works
I want to specify that my output rule should only apply to the contents
I want to specify that for horizontal content it should be overflow:hidden but for
Can I add a column which is I specify as NOT NULL,I don't want
A rather unusual situation perhaps, but I want to specify a private SSH-key to
I have a datawindow where I have a date field. I want to specify
I'm displaying a table with multiple rows and columns. I'm using a JQUERY plugin
I'm trying to work out how to organize an android application that will have
I've been working on a small page in PHP, one that doesn't need the

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.