12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?
- // The file
- $dir = @$_GET['dir'];
- $file = @$_GET['file'];
- $filename = $dir . '/'. $file;
- if(@$_GET['w']==0) {
- $new_width=70;
- } else {
- $new_width=$_GET['w'];
- };
- $mini_filename = 'miniatury/' . $dir . '/' . $new_width . '-' . $file;
- // Content type
- header('Content-type: image/jpeg');
- header('Cache-Control: public');
- if(!file_exists($mini_filename)){
- list($width, $height) = getimagesize($filename);
- $new_height=$height*($new_width/$width);
- if(!file_exists('miniatury/'.$dir)){
- mkdir('miniatury/'.$dir, 0755, true);
- }
- // Resample
- $image_p = imagecreatetruecolor($new_width, $new_height);
- if(preg_match('|\.[jJ][pP][eE]?[gG]$|',$filename)){
- $image = imagecreatefromjpeg($filename);
- } elseif(preg_match('|\.[gG][iI][fF]$|',$filename)){
- $image = imagecreatefromgif($filename);
- } elseif(preg_match('|\.[pP][nN][gG]$|',$filename)){
- $image = imagecreatefrompng($filename);
- }
- imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
- // Output
- //imagejpeg($image_p, null, 70);
- if(!file_exists('miniatury/'.$dir)){
- mkdir('miniatury/'.$dir, 0755, true);
- }
- imagejpeg($image_p, $mini_filename, 70);
- }
- echo file_get_contents($mini_filename);
- ?>
-
|