X-Git-Url: http://positon.org/gitweb/?p=bizou.git;a=blobdiff_plain;f=index.php;h=b260d73c7e1611f472308a2c325a792aed51909a;hp=a26ba60c4639997d3a0f025312fd2cf52e03d251;hb=f20a06743f3feea3b2fe3e1fa15f36c8888403a8;hpb=4a35600a748ef0f13786a8e83c100c15a7b68566 diff --git a/index.php b/index.php index a26ba60..b260d73 100644 --- a/index.php +++ b/index.php @@ -9,7 +9,11 @@ function getPreview($imgFile, $maxSize = THUMB_SIZE) if (! is_file($newImgFile)) { - $img = imagecreatefromjpeg($imgFile); + $ext = strtolower(substr($file, -4)); + if ($ext == ".jpg") + $img = imagecreatefromjpeg($imgFile); + else + $img = imagecreatefrompng($imgFile); $w = imagesx($img); $h = imagesy($img); @@ -34,7 +38,10 @@ function getPreview($imgFile, $maxSize = THUMB_SIZE) imagecopyresampled($newImg, $img, 0, 0, 0, 0, $newW, $newH, $w, $h); - imagejpeg($newImg, $newImgFile); + if ($ext == ".jpg") + imagejpeg($newImg, $newImgFile); + else + imagepng($newImg, $newImgFile); imagedestroy($img); imagedestroy($newImg); @@ -46,7 +53,8 @@ function getPreview($imgFile, $maxSize = THUMB_SIZE) function getAlbumPreview($dir) { foreach (scandir($dir) as $file) if ($file != '.' and $file != '..') { - if (strtolower(substr($file, -4)) == ".jpg") + $ext = strtolower(substr($file, -4)); + if ($ext == ".jpg" or $ext == ".png") return getPreview("$dir/$file"); } @@ -84,7 +92,7 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') else { $ext = strtolower(substr($file, -4)); - if ($ext == ".jpg") + if ($ext == ".jpg" or $ext == ".png") $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file"), "link" => dirname($scriptUrlPath)."/view/$shortPath/$file" ); else $otherFiles[] = array( "name" => $file, "link" => dirname($scriptUrlPath)."/$realDir/$file" );