Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Pravim male glupe brljave thumbnaile!

[es] :: PHP :: Pravim male glupe brljave thumbnaile!

[ Pregleda: 1647 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

stefaneg
Stefan Rakonjac
Kragujevac

Član broj: 38922
Poruke: 130
*.pat-pool.kg.sbb.co.yu.

ICQ: 279404274
Sajt: www.prvatehskola.org


Profil

icon Pravim male glupe brljave thumbnaile!12.01.2006. u 21:42 - pre 222 meseci
Nadao sam se da do ovoga neće doći:

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;


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 );
 }
 
?>


[img]http://www.silentenem.com/pictures/image.php?id=1&template=yes&toppic=yes[/img]
 
Odgovor na temu

erno
Ernad Besirevic
Graz

Član broj: 56944
Poruke: 261
*.tu-graz.ac.at.



Profil

icon Re: Pravim male glupe brljave thumbnaile!13.01.2006. u 11:03 - pre 222 meseci
ImageCopyResized zamjeni sa ImageCopyResampled ;-)
 
Odgovor na temu

stefaneg
Stefan Rakonjac
Kragujevac

Član broj: 38922
Poruke: 130
*.pat-pool.kg.sbb.co.yu.

ICQ: 279404274
Sajt: www.prvatehskola.org


Profil

icon Re: Pravim male glupe brljave thumbnaile!13.01.2006. u 14:26 - pre 222 meseci
Porblem rešen! Stavio sam imagecreatetruecolor() umesto imagecreate() i imagecopyresampled() umesto imagecopyresized(). Tnx!
 
Odgovor na temu

[es] :: PHP :: Pravim male glupe brljave thumbnaile!

[ Pregleda: 1647 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.