favicon2png
Here is a script to download the favicon.ico files from a website and save it as a png file.
You must have imagemagick installed on your server to convert the ico file to png.
-
-
<!--- html code ---->
-
<form action="?" method="post">
-
<input id="site" name="site" type="text"
-
value="<?php echo $_POST['site']; ?/>" />
-
<input type="submit" />
-
</form>
-
-
< ?php
-
//--- favicon2png by Alireza Balouch @ swape.net 2008
-
-
if($_POST['site'] != ''){
-
-
//finding the hostname
-
$host = $host['host'];
-
$filename = 'img/' . $host . '.png';
-
-
// getting the favicon
-
$contents = stream_get_contents($handle);
-
-
file_put_contents('fav.ico' , $contents );
-
// converting to png
-
$StrExec = '/usr/local/bin/convert fav.ico -resize 24x24\> ' . $filename ;
-
}
-
}
-
?>
Semi-transparent png fix in IE6 with CSS
This example shows how you can show semi-transparent png images in IE and don't mess up the code in other browsers. It uses only CSS and no JavaScript.I use the attribute style to make a style for other browsers then IE. And I'm using the filter style that works only for IE in the normal section.But first you have to make a semi transparent png image.
Then make an div layer and set a class name "mydiv"
And here is the CSS code:
-
.mydiv{
-
background-repeat: repeat;
-
position: relative;
-
display: block;
-
width:250px;
-
height:200px;
-
text-align: center;
-
/* Mozilla Firefox and other non IE based browsers ignores the filter style*/
-
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( enabled=true, sizingMethod=scale src="back_g.png");
-
}
-
-
/* IE ignores this part IE can not read styles with [attribute]*/
-
.mydiv[class]{
-
background-image: url(back_g.png);
-
}
-
body{
-
background-image: url(BG.png);
-
background-repeat: repeat;
-
}
Since IE can not show semi-transparent png images, we have to use the filter style that only works in ie. But if we use this code we have to make sure that other browsers can show the png file as well. So we use the styles with attributes. And since IE can not read this part, we can put everything that IE dose not need to read there.