|
Posted by MS on 01/20/06 02:47
System Set-up
PHP 4.4.0
GD version 2.0.28
I am trying to create a thumbnail on the fly from an external URL and then
save it on my server...
The Problem seems to be with the line...
$thumb = imagecreatetruecolor($thumbwidth,$thumbheight);
When checked the $thumb contains a Bool type and no value is set;
I have read http://uk.php.net/imagecreatetruecolor which states....
" Depending on your PHP and GD versions this function is defined or not.
With PHP 4.0.6 through 4.1.x this function always exists if the GD module is
loaded, but calling it without GD2 being installed PHP will issue a fatal
error and exit. With PHP 4.2.x this behaviour is different in issuing a
warning instead of an error. Other versions only define this function, if
the correct GD version is installed."
So my question is... does PHP 4.4.0 use imagecreatetruecolor()?
I get the same issue if i change imagecreatetruecolor to imagecreate.
I also tried the
$fh=fopen($saveto,'w');
fclose($fh);
before the imagejpeg() as suggested at php.net, which does create the file
but is empty after the script is run.
My Code is as follows...
--
$pic = imagecreatefromjpeg($image['df_image_url']);
$thumb = @imagecreatetruecolor($thumbwidth,$thumbheight)
or $thumb = imagecreate($thumbwidth,$thumbheight);
$white = imagecolorallocate($thumb,255,255,255);
imagefilledrectangle($thumb,0,0,$thumbwidth,$thumbheight,$white);
imagecopyresized($thumb,$pic,
0,0, // Thumb Position
0,0, // Original Position
$thumbwidth,$thumbheight, // thumbsize
$origwidth,$origheight // original size
);
$saveto = 'home/www/sitename.com/images/imagesthumbs/'.$image['df_id'] .
'.jpg';
imagejpeg($thumb,$saveto);
--
[Back to original message]
|