/    Sign up×
Community /Pin to ProfileBookmark

Transparency mangles images in IE

After a very, very long process of elimination, I discovered that a problem I’m having with image artifacting in a script I’m writing is related simply to style rules. I’m adjusting the opacity of an image with the properties “opacity” (for standards compliant) and “filter:alpha(opacity=x)” (for IE). Here’s the IE-relevant code:

[code=html]<head>
<style type=”text/css”>
#transparent {
filter:alpha(opacity=60);
}
</style>
</head>
<body>
<img id=”transparent” src=”image.jpg” /><br />
</body>[/code]

View the example at this link and you’ll see what problem this is creating in IE:
[url]http://tarsus.freehostia.com/image_test.html[/url]
(For certain in IE6, but I believe it’s happening in IE7 too.) I chose an image that gets particularly mangled, but this happens to some degree with any fairly dark image.

My JavaScript uses these style rules to accomplish a fading in/fading out effect. I’ve put a band-aid on the problem by setting both rules to an empty string when fading in is finished, so the image looks fine when not fading. But, of course, during the fade the artifacting is there.

Anyone have an idea how to fix this?

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelJul 15.2008 — yeah, -pixelates in IE7 too..


Maybe some along the lines of:[code=html]#transparent { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=&#8217;imagePATH/imageNAME.jpg&#8217;,sizingMethod=&#8217;scale&#8217;);
}[/code]
What image program are you using? Was the image saved using 'for web' colors?

Note "path/imageNAME.jpg" as "[B]src=' '[/B] "
Copy linkTweet thisAlerts:
@tarsusauthorJul 15.2008 — Don't know about how it was saved - just grabbed that one off the Internet. However, I can't rely on images being saved in a specific way (that is, if it can be helped!), because I'm designing this script to be very, very versatile. It's designed to allow a user to simply dump any number of images, any format, any size, into a directory, and the script will transform all images in that directory into an interactive slideshow.

I gave it a try, but I'm afraid I have little experience with using this style property and am not sure how you mean it to be incorporated. How do I also use the filter property to specify the opacity? This is what I tried:

[code=html]<head>
<title>Image Test</title>
<style type="text/css">
#transparent {

filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='dark-knight.jpg',sizingMethod='scale'):alpha(opacity=60);
}
</style>
</head>
<body>
<img id="transparent" src="dark-knight.jpg" />
</body>[/code]


And I also tried:

[code=html]filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='dark-knight.jpg',sizingMethod='scale',opacity=60);[/code]

But I'm not at all sure I'm using that right.
Copy linkTweet thisAlerts:
@tarsusauthorJul 15.2008 — Some research showed me that more than one filter is applied simply with whitespace between:

[code=html]filter: alpha(opacity=50) progid:DXImageTransform.Microsoft.AlphaImageLoader(src='dark-knight.jpg',sizingMethod='scale');[/code]

Or the full alpha filter:

[code=html]filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50) progid:DXImageTransform.Microsoft.AlphaImageLoader(src='dark-knight.jpg',sizingMethod='scale');[/code]

No luck. As long as the alpha filter is on, the image gets ruined.

What's amazing to me is that this doesn't happen [I]all the time[/I] for any developer using transparency on an image. The other images I'm working with aren't nearly as bad as this one, but there are noticeable scattered specks on many of them. These are images I grabbed from many different places on the web, just for testing purposes, so the problem can't be isolated to an issue with saving the images. No one has run into this before?
×

Success!

Help @tarsus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...