PHP - phpthumb class - resize image on the fly from URL

822 Views Asked by At

I would like to create a script which will be create a bigger or smaller image (all images in my script should be 170 x 200 px - if picture is bigger, script will create a smaller picture. If picture is smaller, script will create a bigger image).

I have these code:

require_once 'phpThumb-master/phpThumb.php';

try
{
     $thumb = PhpThumbFactory::create('http://page.com/image.jpg');
}
catch (Exception $e)
{
     // handle error here however you'd like
}

$thumb->adaptiveResize(175, 175);
$thumb->show();

But I get this:

phpThumb() v1.7.14-201602170915 http://phpthumb.sourceforge.net

ERROR: missing hash

Where is a problem?

1

There are 1 best solutions below

3
On

If $PHPTHUMB_CONFIG['high_security_enabled'] is set to true in phpThumb.config.php, you need hash.

Set it to false or try something like this:

echo '<img src="'.htmlspecialchars(phpThumbURL('src=/images/test.jpg&w=100', 'path/to/your/phpThumb.php')).'">';