Click to See Complete Forum and Search --> : GD Problem!


wings@volkan-di
03-12-2008, 11:54 AM
Hi Guys,

I recently moved from a host, and I am having trouble with GD. I have a simple script:


<?
//GET COMMON FUNCTIONS
include_once("../common.php");

header("Content-type: image/jpeg");
session_start();
// create an array to hold directory list
$results = array();

// create a handler for the directory
$handler = opendir("../images/ver/");

$picture = $_GET[pictureid];
$decoded = base64_decode($picture);
$split = explode(" ", $decoded);
$_SESSION[session_actual_veri_image] = $split[0];
$im = @imagecreatefromjpeg("http://www.****.co.uk/images/ver/$split[0].jpg");
imagejpeg($im);
imagedestroy($im);
?>


Running on PHP 5.2.5 with GD 2.0.34, and it outputs the errors:

<br />
<b>Warning</b>: imagejpeg(): supplied argument is not a valid Image resource in <b>/home/sites/*****/public_html/cp/randomimage.php</b> on line <b>18</b><br />
<br />
<b>Warning</b>: imagedestroy(): supplied argument is not a valid Image resource in <b>/home/sites/*****/public_html/cp/randomimage.php</b> on line <b>19</b><br />


I looked though pages and pages on google but couldnt find what was causing the problem... Any ideas?

Any help would be GREATLY appreciated

V

TheBearMay
03-12-2008, 12:06 PM
Off the top of my head it sounds like the imagecreatefromjpeg failed.

Znupi
03-12-2008, 12:33 PM
Try not to suppress errors that may be outputted by imagecreatefromjpeg() and tell us what happens (remove the '@' before the function call). Probably the new host's allow_url_fopen (http://www.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen) php.ini directive is set to false.

wings@volkan-di
03-12-2008, 02:24 PM
Hi Guys,

Thanks for the replys!

I removed the '@' in front of imagecreatefromjpeg

and the errors in the source are now:

<br />
<b>Warning</b>: imagecreatefromjpeg(http://www.******.co.uk/images/ver/plane.jpg) [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: failed to open stream: Connection refused in <b>/home/sites/******/public_html/cp/randomimage.php</b> on line <b>17</b><br />
<br />
<b>Warning</b>: imagejpeg(): supplied argument is not a valid Image resource in <b>/home/sites/******/public_html/cp/randomimage.php</b> on line <b>18</b><br />

<br />
<b>Warning</b>: imagedestroy(): supplied argument is not a valid Image resource in <b>/home/sites/******/public_html/cp/randomimage.php</b> on line <b>19</b><br />

images/var is all Chmoded to 777 (recursive)

And from phpinfo:

Directive Local Value Master Value
allow_call_time_pass_reference On On
allow_url_fopen On On
allow_url_include On On

Am I missing something?

wings@volkan-di
03-12-2008, 04:05 PM
Well managed to get it working by changing

$im = @imagecreatefromjpeg("http://www.****.co.uk/images/ver/$split[0].jpg");

to

$im = @imagecreatefromjpeg("../images/ver/$split[0].jpg");

Thanks for all your help!!