# Thumbnail php script with flash

**URL:** https://forum.kirupa.com/t/thumbnail-php-script-with-flash/229388
**Category:** Uncategorized
**Created:** [June 16, 2007, 4:28pm UTC](https://forum.kirupa.com/t/thumbnail-php-script-with-flash/229388 "2007-06-16T16:28:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![danda](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@danda](https://forum.kirupa.com/u/danda)
#### Post date: [June 16, 2007, 4:28pm UTC](https://forum.kirupa.com/t/thumbnail-php-script-with-flash/229388/1 "2007-06-16T16:28:09Z")

</div>

hello,

i want to load external images in my flash websites.

the images are thumbnails generated by php.

but it seems that flash doesn’t properly detects the file size.

any suggestions?

kind regards,  
dnd

```php
<?php  

ob_start();

$image = $_GET["img"];
$project = $_GET["project"];

$h="400";
$w="680";

$image="../data/projects/".$project."/".$image;

$max_width = $w; 
$max_height = $h; 

$size = getimagesize($image); 
$width = $size[0]; 
$height = $size[1]; 

$x_ratio = $max_width / $width; 
$y_ratio = $max_height / $height; 

if ( ($width <= $max_width) && ($height <= $max_height) ) { 
$tn_width = $width; 
$tn_height = $height; 
} 
else if (($x_ratio * $height) < $max_height) { 
$tn_height = ceil($x_ratio * $height); 
$tn_width = $max_width; 
} 
else { 
$tn_width = ceil($y_ratio * $width); 
$tn_height = $max_height; 
} 

$src = imagecreatefromjpeg($image); 
$dst = imagecreatetruecolor($tn_width,$tn_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, 
$tn_width,$tn_height,$width,$height); 
header("Content-type: image/jpeg"); 
imagejpeg($dst, null, 100); 
imagedestroy($src); 
imagedestroy($dst);

header("Content-Length: ". ob_get_length());
// flush the output
ob_end_flush();

?> 

```
