Results 1 to 6 of 6
  1. #1
    New Member
    Join Date
    Aug 2006
    Location
    London
    Posts
    2

    Background of a png image transparent using Java Script

    Is any one can tell me how can I make the background(only) of a png image transparent using Java Script?

  2. #2
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    I assume you want this to happen in response to something, like a mouseover or some other event? Otherwise you'd just make it a transparent background when you make the image.

    If so, my suggestion would be to make two images, one with the transparent background and one without. Then use JavaScript to swap the images as required.

    If you're not sure how to proceed, let me know exactly what it is you're trying to do and I'll see if I can give you the right code.
    Dave Owen
    MediaCollege.com

  3. #3
    New Member
    Join Date
    Aug 2006
    Location
    London
    Posts
    2
    Hi,
    Thanks for the response...My actual requirement is to load a png image file with only the background as transparent. For eg: I have a piechart in a png file format, I want to super-impose it on a geographical map with only the circular region of the pie-chart being visible. The remaining rectangular white portion around the circular pie should be made transparent, so that the map behind it is seen through. I'm not using any tools or softwares other than MS-Paint. Coding is done using JavaScript and plain HTML.

    Kindly let me know if there's any work-around for this requirement. Thankyou in anticipation

  4. #4
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Quote
    Quote: ppma
    My actual requirement is to load a png image file with only the background as transparent.
    The PNG file itself must be transparent - you can't use javaScript to make it happen. You need to open the file in a graphics editor and make the background transparent.

    Quote
    Quote: ppma
    I'm not using any tools or softwares other than MS-Paint.
    There's your problem. MS Paint will probably not let you do this. I say "probably" because there is one small chance - in the menu go to Image > Attributes and see if there's a transparency option. If so, you might be able to set the background colour as transparent.

    Unfortunately there are many different versions of MS Paint and I believe that only some (possibly older) versions have this feature.

    If you are still stuck, you could upload the PNG file with your reply and I'll see if I can make it transparent for you.
    Dave Owen
    MediaCollege.com

  5. #5
    Doesn't IE have a problem with PNG? I have noticted that it does not support transparency very well in this format, especially in relation to shadows/ blurs.

  6. #6
    Quote
    Quote: donnied
    View Post
    Doesn't IE have a problem with PNG? I have noticted that it does not support transparency very well in this format, especially in relation to shadows/ blurs.
    I heard it too. IE not support PNG.. May be a new version....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Subscribe to us on YouTube