U prethodnom postu sam pitao da li još nekome ko koristi easyphp brljavi thumbnail-e. E pa izgleda da ne, pošto sam danas postavio istu skriptu na net i problem je ostao... Evo isečka koda za pravljenje thumbnaila pa ako neko vidi grešku neka kaže
Code:
Deo iz switcha za izbor tipa slike:
case "image/gif":
include "resize_gif.php";
ob_start();
resize_gif($_FILES['file']['tmp_name'], 120, 120);
$resizedImage = ob_get_contents();
ob_end_clean();
break;
Deo iz switcha za izbor tipa slike:
case "image/gif":
include "resize_gif.php";
ob_start();
resize_gif($_FILES['file']['tmp_name'], 120, 120);
$resizedImage = ob_get_contents();
ob_end_clean();
break;
Code:
resize_gif.php:
<?php
function resize_gif ($image, $newWidth, $newHeight)
{
//Open the gif file to resize
$srcImage = ImageCreateFromGif( $image );
//obtain the original image Height and Width
$srcWidth = ImageSX( $srcImage );
$srcHeight = ImageSY( $srcImage );
// the follwing portion of code checks to see if
// the width > height or if width < height
// if so it adjust accordingly to make sure the image
// stays smaller then the $newWidth and $newHeight
if( $srcWidth < $srcHeight )
{
$destWidth = $newWidth * $srcWidth/$srcHeight;
$destHeight = $newHeight;
}
else
{
$destWidth = $newWidth;
$destHeight = $newHeight * $srcHeight/$srcWidth;
}
// creating the destination image with the new Width and Height
$destImage = imagecreate( $destWidth, $destHeight);
//copy the srcImage to the destImage
ImageCopyResized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight );
//create the gif
if (function_exists("imagegif"))
{
imagegif ($destImage);
}
elseif (function_exists("imagejpeg"))
{
imagejpeg ($destImage, "", 100);
}
elseif (function_exists("imagepng"))
{
imagepng ($destImage);
}
elseif (function_exists("imagewbmp"))
{
imagewbmp ($destImage);
}
else die("No image support in this PHP server");
//fre the memory used for the images
ImageDestroy( $srcImage );
ImageDestroy( $destImage );
}
?>
resize_gif.php:
<?php
function resize_gif ($image, $newWidth, $newHeight)
{
//Open the gif file to resize
$srcImage = ImageCreateFromGif( $image );
//obtain the original image Height and Width
$srcWidth = ImageSX( $srcImage );
$srcHeight = ImageSY( $srcImage );
// the follwing portion of code checks to see if
// the width > height or if width < height
// if so it adjust accordingly to make sure the image
// stays smaller then the $newWidth and $newHeight
if( $srcWidth < $srcHeight )
{
$destWidth = $newWidth * $srcWidth/$srcHeight;
$destHeight = $newHeight;
}
else
{
$destWidth = $newWidth;
$destHeight = $newHeight * $srcHeight/$srcWidth;
}
// creating the destination image with the new Width and Height
$destImage = imagecreate( $destWidth, $destHeight);
//copy the srcImage to the destImage
ImageCopyResized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight );
//create the gif
if (function_exists("imagegif"))
{
imagegif ($destImage);
}
elseif (function_exists("imagejpeg"))
{
imagejpeg ($destImage, "", 100);
}
elseif (function_exists("imagepng"))
{
imagepng ($destImage);
}
elseif (function_exists("imagewbmp"))
{
imagewbmp ($destImage);
}
else die("No image support in this PHP server");
//fre the memory used for the images
ImageDestroy( $srcImage );
ImageDestroy( $destImage );
}
?>
[img]http://www.silentenem.com/pictures/image.php?id=1&template=yes&toppic=yes[/img]