PDA

View Full Version : Thumbnails on the fly


arzach
09-16-2003, 07:44 AM
is it possible to load a jpg that doesn't exist on the server?
i can show it in the browser using a script like this below, but how can i load it in flash??

<?php
//setup
$max_w = 80;
$max_h = 80;

//load image
$img=null;
$img=@imagecreatefromjpeg("test.jpg");
if ($img) {
$w = imagesx($img);
$h = imagesy($img);
$scale = min($max_w/$w, $max_h/$h);
if ($scale < 1) {
$new_w = floor($scale*$w);
$new_h = floor($scale*$h);
$tmp_img = imagecreatetruecolor($new_w, $new_h);
imagecopyresized($tmp_img, $img, 0, 0, 0, 0,$new_w, $new_h, $w, $h);
imagedestroy($img);
$img = $tmp_img;

}

} else {
echo "errore";
}

header("Content-type: image/jpeg");
imagejpeg($img);
?>