View Full Version : imageCreateFromJPEG Not working
lifeisboost
24th February 2006, 12:11
Hello All,
I used the perfect setup for fedora C3, GD is installed. My only issue is imageCreateFromJPEG does not work. does anyone have any help they can offer? do i need to recompile php diffrerently?
falko
24th February 2006, 15:16
Any error messages? Anything in the logs?
lifeisboost
25th February 2006, 00:37
here is a snippet of the log
Undefined variable: src in /home/www/web5/web/getimgclass.php on line 6, referer: http$
[client 166.102.29.115] PHP Warning: imagesx(): supplied argument is not a valid Image resource in /home/www/web5/web/getim$
[client 166.102.29.115] PHP Warning: imagesy(): supplied argument is not a valid Image resource in /home/www/web5/web/getim$
[client 166.102.29.115] PHP Warning: imagealphablending(): supplied argument is not a valid Image resource in /home/www/web$
[client 166.102.29.115] PHP Warning: imagecopy(): supplied argument is not a valid Image resource in /home/www/web5/web/get$
[client 166.102.29.115] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home
what this script does is add a watermark to each image as it is viewed and is all custom coded.
lifeisboost
25th February 2006, 03:24
also imageCreateFromPNG will not work. i check php config and it shows the correct GD version installed and imagmagick is installed im kinda stumped
till
25th February 2006, 10:28
For me these errors looks like you are either pointing the PHP image functions to an non image file or the path to the image file is incorrect.
lifeisboost
25th February 2006, 14:41
this is the scrip that isn;t working. it pulls the images from a database. and they are all in the correct locations.
<?php
Header( "Content-type: image/jpeg");
$im = "/home/www/web5/web/watermark/sfslogo.png";
$src = "$src";
// create the resource id
$image_id = imageCreateFromPNG($im);
// get image size
$im_x = ImageSX($image_id);
$im_y = ImageSY($image_id);
// background image
$backgroundimage = imageCreateFromJPEG($src);
$bk_x = ImageSX($backgroundimage);
$bk_y = ImageSY($backgroundimage);
$dest_x = ( $bk_x / 2 ) - ( $im_x / 2 );
$dest_y = ( $bk_y / 2 ) - ( $im_y / 2 );
// merge the two together with alphsablending on!
ImageAlphaBlending($backgroundimage, true);
imagecopy($backgroundimage, $image_id, $dest_x, $dest_y, 0, 0, $im_x, $im_y);
ImageJPEG($backgroundimage);
// destroy the memory
ImageDestroy($backgroundimage);
ImageDestroy($image_id);
?>
till
26th February 2006, 09:24
Does this script works on another server. I'am pretty sure that the problem is related to the .png file that you try to open. If the imagecreate functions where not compiled in correctly in your php you would get different error messages.
falko
26th February 2006, 16:40
I think you have to check the script:
<?php
Header( "Content-type: image/jpeg");
$im = "/home/www/web5/web/watermark/sfslogo.png";
$src = "$src";
// create the resource id
$image_id = imageCreateFromPNG($im);
// get image size
$im_x = ImageSX($image_id);
$im_y = ImageSY($image_id);
// background image
$backgroundimage = imageCreateFromJPEG($src);
$bk_x = ImageSX($backgroundimage);
$bk_y = ImageSY($backgroundimage);
$dest_x = ( $bk_x / 2 ) - ( $im_x / 2 );
$dest_y = ( $bk_y / 2 ) - ( $im_y / 2 );
// merge the two together with alphsablending on!
ImageAlphaBlending($backgroundimage, true);
imagecopy($backgroundimage, $image_id, $dest_x, $dest_y, 0, 0, $im_x, $im_y);
ImageJPEG($backgroundimage);
// destroy the memory
ImageDestroy($backgroundimage);
ImageDestroy($image_id);
?>
$src is not defined in that script, that's why imageCreateFromJPEG($src) fails.
lifeisboost
26th February 2006, 18:10
the script works perfectly on a cpanel server. the coder imworking with insists its the server configuration :( the source comes from another file that calls this script.
till
26th February 2006, 19:20
Please make a new PHP script with the content:
<?php
$image_id = imageCreateFromPNG("/home/www/web5/web/watermark/sfslogo.png");
?>
Make sure you deactivate PHP safemode in this website and that the file /home/www/web5/web/watermark/sfslogo.png really exist. Then call the script in a webbrowser. Do you get an error?
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.