Subversion Repositories Applications.galerie

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 jp_milcent 1
<?php
2
 
3
if($_GET['img'] == "")
4
exit;
5
 
6
$_image_ = urldecode( $_GET['img'] );
7
 
8
$_width_min_ = intval($_GET['width']);
9
$_height_min_ = intval($_GET['height']);
10
$_quality_ = intval($_GET['quality']);
11
 
12
$new_w = $_width_min_;
13
$imagedata = getimagesize($_image_);
14
 
15
if(!$imagedata[0])
16
exit();
17
 
18
$new_h = (int)($imagedata[1]*($new_w/$imagedata[0]));
19
 
20
if(($_height_min_) AND ($new_h > $_height_min_)) {
21
	$new_h = $_height_min_;
22
	$new_w = (int)($imagedata[0]*($new_h/$imagedata[1]));
23
}
24
 
25
if(strtolower(substr($_image_,-3)) == "jpg") {
26
  header("Content-type: image/jpg");
27
  $dst_img=ImageCreate($new_w,$new_h);
28
  $src_img=ImageCreateFromJpeg($_image_);
29
  $dst_img = imagecreatetruecolor($new_w, $new_h);
30
  imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
31
  $img = Imagejpeg($dst_img, '', $_quality_);
32
}
33
 
34
if(substr($_GET['img'],-3) == "gif") {
35
  header("Content-type: image/gif");
36
  $dst_img=ImageCreate($new_w,$new_h);
37
  $src_img=ImageCreateFromGif($_image_);
38
  ImagePaletteCopy($dst_img,$src_img);
39
  ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
40
  $img = Imagegif($dst_img,'', $_quality_);
41
}
42
 
43
if(substr($_GET['img'],-3) == "png") {
44
  header("Content-type: image/png");
45
  $dst_img=ImageCreate($new_w,$new_h);
46
  $src_img=ImageCreateFromPng($_image_);
47
  ImagePaletteCopy($dst_img,$src_img);
48
  ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));
49
  $img = Imagepng($dst_img,'', $_quality_);
50
}
51
 
52
?>