Page 1 of 1

Problem with images?

Posted: Tue Jul 29, 2003 6:04 pm
by InternetX
Hello...
PHP is showing me errors, but I don't know why.
The errors:

Warning: imagejpeg(): supplied argument is not a valid Image resource in h:\wampp1\htdocs\profile.php on line 4
Warning: imagedestroy(): supplied argument is not a valid Image resource in h:\wampp1\htdocs\profile.php on line 5

And the source code:

<?php
IF($pic == "create" && isset($uid) && isset($pid) && isset($pno)) {
$image = @ImageCreateFromJPEG("gallery/".$uid.".".$pid.".".$pno.".jpg");
ImageJpeg($image);
ImageDestroy($image);
exit;
}
?>

What's wrong with my PHP or with my Script?
I don't find any errors :(
Please help me :(

Posted: Tue Jul 29, 2003 7:14 pm
by Judas
this is a "path error" check the image path before processing you should remove the @ in front of "@ImageCreateFromJPEG("gallery/".$uid.".".$pid.".".$pno.".jpg");" then check the path in the warning msg

b_t_w a beter way for naming is a underscore "_" inplace of a dot "."

Posted: Tue Jul 29, 2003 7:36 pm
by InternetX
I already checked the path... the file exists...
But the script don't load this file :(
I will test it with "_" instead of "."

Thanks...

Posted: Tue Jul 29, 2003 7:56 pm
by InternetX
The script doesn't work because in the ImageCreateFromJPEG() command
is the file not in the same directory ("gallery/")
If the file is in the same dir the script works...
Can I correct or bypass this?

Posted: Wed Jul 30, 2003 4:34 am
by Judas
the imageCreate must read a existing file

i thought, for output u can use ImageJpeg($image,"path_to_write_image_to");

Posted: Wed Jul 30, 2003 4:44 am
by pootergeist
use a root path to define the imagecreate

ImageCreateFromJPEG('/home/site/pub/gallery/' .$args. '.jpg');

As you are not doing anything to the image, why not just run a readfile and output it directly (sure saves the overhead of converting it to .gd format then back to jpeg - about 10 times the process)
I assume you are calling that script within an img src tag, so you'd also need a header output.

if(file_exists('/home/site/pub/' .$args. '.jpg');
{
header("Content-type: image/jpeg");
readfile('/home/site/pub/' .$args. '.jpg');
}

Posted: Wed Jul 30, 2003 7:36 am
by InternetX
Ok, Thanks :)