PHP Classes

show a thumbnail

Recommend this page to a friend!

      Simple Thumbnails  >  All threads  >  show a thumbnail  >  (Un) Subscribe thread alerts  
Subject:show a thumbnail
Summary:show a thumbnail
Author:Giovani Thomé
Date:2013-01-28 13:54:19
Update:2013-01-30 14:26:44

  1. show a thumbnail   Reply   Report abuse  
Picture of Giovani Thomé Giovani Thomé - 2013-01-28 13:54:20
Great class!
Well, I want use this to show images using your class inside the tag 'img'.
I tryed using this:

$teste=Thumbnails::createThumb('gauchopedia1.jpg','null', 100,100, Thumbnails::IMAGE_CENTER | Thumbnails::IMAGE_TOUCH_OUTSIDE | Thumbnails::IMAGE_POS_RIGHT, Thumbnails::IMAGE_FORMAT_PNG, array('r'=>255,'g'=>255,'b'=>255));
echo "<img src=". $teste . ">";

It didn't work.

Can you help me with this?


  2. Re: show a thumbnail   Reply   Report abuse  
Picture of Carlos Sosa Carlos Sosa - 2013-01-30 14:26:44 - In reply to message 1 from Giovani Thomé
Hello Giovanim,

Thanks you for appreciation !

The class was a problem with the method createThumb and destination as NULL, this was corrected and you should update your version of the class.

You also have an error with the NULL value, can't be passed how 'NULL' using quotes.

To create thumbnail:

$obj=Thumbnails::createThumb('gauchopedia1.jpg', NULL /*Correct NULL Val*/, 100,100, Thumbnails::IMAGE_TOUCH_OUTSIDE | Thumbnails::IMAGE_POS_RIGHT, Thumbnails::IMAGE_FORMAT_PNG, array('r'=>255,'g'=>255,'b'=>255));

//Into a variable:
$img = $obj->getThumbnailAsString();
echo '<img src="data:image/png;base64,'. base64_encode($img) .'">';

//or Print:

header("Pragma: public");
header('Content-disposition: filename=image_thumb.png');
header("Content-type: image/png");
header('Content-Transfer-Encoding: binary');
//Using simplified method

You can also find more examples into the source code of the class.

I will plan expand the features of the class. Allowing transparent color, pass colors as hex value or the name, and another many things. You can follow me in GitHub