Update of /cvsroot/openfirst/photogallery
In directory sc8-pr-cvs1:/tmp/cvs-serv17595
Modified Files:
galleryglobals.php preview.php
Log Message:
Change preview.php to allow more image formats to be available (assuming GD is compiled with support for them).
Index: galleryglobals.php
===================================================================
RCS file: /cvsroot/openfirst/photogallery/galleryglobals.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** galleryglobals.php 1 Jun 2003 04:17:15 -0000 1.1.1.1
--- galleryglobals.php 2 Jun 2003 23:26:49 -0000 1.2
***************
*** 31,35 ****
//Declare image types allowed for uploading/previewing
! $imgtypes = "gif,jpg,png,bmp";
! ?>
\ No newline at end of file
--- 31,35 ----
//Declare image types allowed for uploading/previewing
! $imgtypes = "gif,jpg,jpeg,png,bmp";
! ?>
Index: preview.php
===================================================================
RCS file: /cvsroot/openfirst/photogallery/preview.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** preview.php 2 Jun 2003 11:42:04 -0000 1.1
--- preview.php 2 Jun 2003 23:26:49 -0000 1.2
***************
*** 28,43 ****
$img = $_GET["img"];
! header("Content-Type: image/png");
!
! // Take the image passed to us, rescale it to preview-size. Then display it.
! $src_img = imagecreatefrompng("$img");
! $new_h = 100;
! $new_w = 100;
! $dst_img = imagecreatetruecolor($new_w,$new_h);
! imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img));
! imagepng($dst_img);
! imagedestroy($dst_img);
! imagedestroy($src_img);
?>
--- 28,106 ----
$img = $_GET["img"];
! include("galleryglobals.php");
! $imgt = explode(",", $imgtypes);
+ for ($x = 0; $x < count($imgt); $x++) {
+ $imgt[$x] = strtolower($imgt[$x]);
+ if($imgt[$x] == strtolower(substr($img, strrpos($img, ".") + 1, strlen($img) - strrpos($img, ".")))) {
+ if($imgt[$x] == "png") {
+ if(function_exists(imagepng) == true) {
+ header("Content-Type: image/png");
+ $src_img = imagecreatefrompng("$img");
+ $new_h = 100;
+ $new_w = 100;
+ $dst_img = imagecreatetruecolor($new_w,$new_h);
+ imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img));
+ imagepng($dst_img);
+ imagedestroy($dst_img);
+ imagedestroy($src_img);
+ } else {
+ header("Location: thumbnailerror.png");
+ }
+ $displayed = "true";
+ } elseif($imgt[$x] == "jpg" || $imgt[$x] == "jpeg") {
+ if(function_exists(imagejpeg) == true) {
+ header("Content-Type: image/jpeg");
+ $src_img = imagecreatefromjpeg("$img");
+ $new_h = 100;
+ $new_w = 100;
+ $dst_img = imagecreatetruecolor($new_w,$new_h);
+ imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img));
+ imagejpeg($dst_img);
+ imagedestroy($dst_img);
+ imagedestroy($src_img);
+ } else {
+ header("Location: thumbnailerror.png");
+ }
+ $displayed = "true";
+ } elseif($imgt[$x] == "gif") {
+ if(function_exists(imagegif) == true) {
+ header("Content-Type: image/gif");
+ $src_img = imagecreatefromgif("$img");
+ $new_h = 100;
+ $new_w = 100;
+ $dst_img = imagecreatetruecolor($new_w,$new_h);
+ imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img));
+ imagegif($dst_img);
+ imagedestroy($dst_img);
+ imagedestroy($src_img);
+ } else {
+ header("Location: thumbnailerror.png");
+ }
+ $displayed = "true";
+ } elseif($imgt[$x] == "bmp") {
+ if(function_exists(imagebitmap) == true) {
+ header("Content-Type: image/bmp");
+ $src_img = imagecreatefrombitmap("$img");
+ $new_h = 100;
+ $new_w = 100;
+ $dst_img = imagecreatetruecolor($new_w,$new_h);
+ imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img));
+ imagebitmap($dst_img);
+ imagedestroy($dst_img);
+ imagedestroy($src_img);
+ } else {
+ header("Location: thumbnailerror.png");
+ }
+ $displayed = "true";
+ } else {
+ header("Location: thumbnailerror.png");
+ $displayed = "true";
+ }
+ }
+ }
+ if($displayed != "true") {
+ header("Location: thumbnailerror.png");
+ }
?>
|