note 82722 added to function.imagesavealpha
| From: | phil at unabacus dot net | Date: | Wed, 23 Apr 2008 13:47:54 +0000 |
| Subject: | note 82722 added to function.imagesavealpha | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138697@lists.php.net to get a copy of this message | ||
The comment left by "doggz at mindless dot com" will cause a duplication in layering of
the transparent image - AlphaImageLoader loads the image as if it were a floating layer on top of
the <img> element - so your image will double up.. so don't go thinking something very
strange is happening with your PHP it's the silly browser ;)
The easiest (although not the best) way to get around this is to use the CSS background property
instead of an image src - because as of yet you can't change an image's src dynamically
using currently supported CSS:
<div style="width:200px; height:200px; background: url(my-trans-image.php);
*background:url(); *filter:progid:
DXImageTransform.Microsoft.AlphaImageLoader(src='my-trans-image.php',
sizingMethod='scale');"></div>
The above (although not pretty) keeps the image loaded as a background for any good browser as they
should ignore the starred (*) CSS items and should support Alpha PNGs natively. IE will listen to
the starred items and blank out the background whilst applying it's AlphaLoader on top.
Obviously you need to know the width and height of your image but you can get this using
getimagesize() or just by hardcoding.
Downsides to know:
1. Unless the user has 'backgrounds enabled when printing' your image wont show up when
the webpage is printed.
2. You can't stretch or shrink a background image - if you change the div's dimensions
from that of the image you will stretch it in IE (due to the 'scale' property - which you
can change for sake of standardness to 'crop') but you will crop it in any other browser.
3. Most browsers treat images and backgrounds differently, in load priority and in the way the user
can interact with them.
Other Options:
Other methods resort to using JavaScript or Browser Detection on the Server Side.
----
Server IP: 92.48.74.199
Probable Submitter: 81.187.46.163
----
Manual Page -- http://www.php.net/manual/en/function.imagesavealpha.php
Edit -- https://master.php.net/note/edit/82722
Del: integrated -- https://master.php.net/note/delete/82722/integrated
Del: useless -- https://master.php.net/note/delete/82722/useless
Del: bad code -- https://master.php.net/note/delete/82722/bad+code
Del: spam -- https://master.php.net/note/delete/82722/spam
Del: non-english -- https://master.php.net/note/delete/82722/non-english
Del: in docs -- https://master.php.net/note/delete/82722/in+docs
Del: other reasons-- https://master.php.net/note/delete/82722
Reject -- https://master.php.net/note/reject/82722
Search -- https://master.php.net/manage/user-notes.php