views:

111

answers:

1

This is my actual code, I have troubles related with the right visualization of the gif image generated on the fly for my php script. If I access directly to the gif image generated by the script the browser show it good but if I try from my current script through tag img, the browser couldn't show it.

Any suggest friends ?

<?php
$src = imagecreatefromjpeg( 'img/ejemplo-2.jpg' );
list( $width, $height ) = getimagesize( 'img/ejemplo-2.jpg' );
$tmp = imagecreatetruecolor( '300', '300');
imagecopyresampled( $tmp, $src, 0, 0, 0, 0, '300', '300', $width, $height );
$imagen = imagegif( $tmp, "filename.gif" );
$data   = "data:image/gif;base64," . base64_encode( file_get_contents( "filename.gif" ) );
?>

<img src="<?php echo $data; ?>" width="300" height="300" />
A: 

While Opera 7.2+, Firefox, Safari, Netscape, and Mozilla support data URIs, Internet Explorer 5-7 do not. However, Internet Explorer 8 reportedly does, by passing the Acid2 test, making data URLs a viable alternative for embedding smaller decorative images. There are workarounds that you can use for older versions of Internet Explorer.

If you want to get round browser cache issues, append a random generated number onto the end of the img src :

<img src="test.jpg?12345" />
Jim Grant
Thank you so much, was very easy after your suggest jejeje : )
Edwin Sandoval