PDA

View Full Version : Beta 9 Image upload .5 working



Anonymous
07-09-2003, 07:16 PM
Hi !

I already read the previous thread about the thumbnail images not showing-up from 'thumbnail_gd.php'.. Indeed the main image shows-up and exists in the target directory, but, the thumbnail image is not created in the target directory and a broken image is displayed on the edit page.

I am running Beta 9, on UNIX with a GD library >1.62 Looks like the bug has crept back in? Any thoughts are appreciated!

ThanX!

-sk-

RealtyOne
07-09-2003, 07:27 PM
Hi
With beta 9 the gd was fixed and so far no other problems. maybe you have same results for a different reason?

can you upload gif? If you have access to an earlier version (eg1.07) try the gd from it and see if you get the same results. That way we will have a starting point. One of my systems was originally haveing problems with the images but since it was debugged for beta9 i have no problems.
Anyways if you can do a bit of checking would be good.
No error message? need something to start on is all :)

Anonymous
07-09-2003, 07:52 PM
Not sure.. I discovered a new problem however, when I tried to delete the existing .jpg, I received the error:

'There's been a problem -- please contact the site administrator'

The .jpg image was in fact deleted.

Uploading .gif files seems to work just fine..
Deleting .gif files works O.K.

try to re-upload another .jpg: and I get:

'meeting1.jpg has been successfully uploaded.'

The main image is displayed, the thumbnail is a broken image which properties show a valid filename in the target directory. However, this thumbnail file does not exist. Width, height, and size values are empty beneath the broken image. Deleting the image causes the error above...


Ya got me! I'm pretty good with this stuff..I'd write this app myself, but I thought I could save some time.. I can post the URL if you like, everything is configured bone stock.

I appreciate the prompt response!

-sk-

RealtyOne
07-09-2003, 07:58 PM
can you please post a link to a phpinfo file :)

Anonymous
07-09-2003, 08:07 PM
O.K.

Try this:

http://piventures.com/php_info.php


ThanX!

-sk-

RealtyOne
07-09-2003, 08:13 PM
thanx you can remove it now :)

The error you get on delete is failur to find the thumb to delete it so thats no problem.
Since everything looks fine to do this we will need look further and test some more.

Anonymous
07-09-2003, 08:22 PM
<< The error you get on delete....>>

Just the error trapping doing it's job, eh.....


Some food for thought:

The GD library that is bundled with PHP distributions is different than the one the original author distributes.. I am fairly certain that my host uses the bundled version.

Thanks for your help!

-sk-

RealtyOne
07-09-2003, 08:28 PM
I have looked from the admin of your site and this is definately a new problem at the moment i am not sure of a coause.
This problem is being looked for in the current dev version and unless you find a problem we will have to get back to you as soon as we find one.

PS: Your server is not configured to recognise index.php as a page to open in a directory? (yoursite/open-realty/admin without file name)

greengiant
07-09-2003, 08:29 PM
Please Replace your thumnail.gd file with this, and let me know when you have it done.



<?php
function make_thumb &#40;$input_file_name, $input_file_path&#41;
&#123;
// makes a thumbnail using the GD library
global $config;

$quality = 100; // jpeg quality -- the lower the num, the smaller the file size

// first, grab the dimensions of the pic
$imagedata = GetImageSize&#40;"$input_file_path/$input_file_name"&#41;;
$imagewidth = $imagedata&#91;0&#93;;
$imageheight = $imagedata&#91;1&#93;;
$imagetype = $imagedata&#91;2&#93;;
// type definitions
// 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP
// 7 = TIFF&#40;intel byte order&#41;, 8 = TIFF&#40;motorola byte order&#41;
// 9 = JPC, 10 = JP2, 11 = JPX
$thumb_name = $input_file_name; //by default
// the GD library, which this uses, can only resize JPG and PNG
if &#40;$imagetype == 2&#41;
&#123;
// it's a JPG
// figure out the ratio to which it should be shrunk, if at all
$shrinkage = 1;
if &#40;$imagewidth > $config&#91;thumbnail_width&#93;&#41;
&#123;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
&#125;
$dest_height = $shrinkage * $imageheight;
$dest_width = $config&#91;thumbnail_width&#93;;

$src_img = imagecreatefromjpeg&#40;"$input_file_path/$input_file_name"&#41;;
///* old function
//GD Lib is Version 2 or >
//$dst_img = imagecreatetruecolor&#40;$dest_width,$dest_height&#41;;
//imagecopyresampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
//GD Lib is Version <2
//$dst_img = imagecreate&#40;$dest_width,$dest_height&#41;;
//imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
//New Function checks to see if GD2 functions are available for higher quality thumbnails
$gdversion2 = sysB_chkgd2&#40;&#41;;
if &#40;!$gdversion2&#41;
&#123;
echo '<!-- GD Version 1.X Detected -->';
&#125;
else
echo '<!-- GD Version 2.X Detected -->';
&#125;
if &#40;!$gdversion2&#41;
&#123;
$dst_img = imageCreate&#40;$dest_width, $dest_height&#41;;
&#125;
else
&#123;
$dst_img = imageCreateTrueColor&#40;$dest_width, $dest_height&#41;;
&#125;
//copy the original image info into the new image with new dimensions
//checking to see which function is available
if &#40;!$gdversion2&#41;
&#123;
ImageCopyResized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight&#41;;
&#125;
else
&#123;
ImageCopyResampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight&#41;;
&#125;
$thumb_name = "thumb_"."$input_file_name";
imagejpeg&#40;$dst_img, "$input_file_path/$thumb_name", $quality&#41;;
imagedestroy&#40;$src_img&#41;;
imagedestroy&#40;$dst_img&#41;;
&#125; // end if $imagetype == 2
elseif &#40;$imagetype == 3&#41;
&#123;
// it's a PNG
// figure out the ratio to which it should be shrunk, if at all
$shrinkage = 1;
if &#40;$imagewidth > $config&#91;thumbnail_width&#93;&#41;
&#123;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
&#125;
$dest_height = $shrinkage * $imageheight;
$dest_width = $config&#91;thumbnail_width&#93;;

$src_img = imagecreatefrompng&#40;"$input_file_path/$input_file_name"&#41;;
$dst_img = imagecreate&#40;$dest_width,$dest_height&#41;;
imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
$thumb_name = "thumb_"."$input_file_name";
imagepng&#40;$dst_img, "$input_file_path/$thumb_name"&#41;;
imagedestroy&#40;$src_img&#41;;
imagedestroy&#40;$dst_img&#41;;
&#125; // end if $imagetype == 3


return $thumb_name;
&#125; // end function make_thumb
function sysB_chkgd2&#40;&#41;
&#123;
global $config;
$rep=false;
if&#40;isset&#40;$GLOBALS&#91;"gBGDVersion"&#93;&#41;&#41;
&#123;
$rep=$GLOBALS&#91;"gBGDVersion"&#93;;
&#125;
else
&#123;
if&#40;function_exists&#40;"gd_info"&#41;&#41;
&#123;
$gdver=gd_info&#40;&#41;;
if&#40;strstr&#40;$gdver&#91;"GD Version"&#93;,"1."&#41;!=false&#41;
&#123;
$rep=false;
&#125;
else
&#123;
$rep=true;
&#125;
&#125;
else
&#123;
$size =40;
$b=imagettfbbox &#40;$size,0,$config&#91;basepath&#93;.'/include/font/Dustismo.ttf',"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ"&#41;;

if&#40;&#40;$size+1&#41;<abs&#40;$b&#91;5&#93;-$b&#91;3&#93;&#41;&#41;
&#123;
$rep=true;
&#125;
&#125;
$GLOBALS&#91;"gBGDVersion"&#93;=$rep;
&#125;
return $rep;
&#125;
?>

Anonymous
07-09-2003, 08:36 PM
O.K. done...

PS: I know about the .PHP indexing, i just haven't got round' to fixing THAT yet...


-sk-

Anonymous
07-09-2003, 10:03 PM
Your source code has a minor syntax problem...

line 46 reads:

else
echo '<!-- GD Version 2.X Detected -->';
}


and should read:

else
{
echo '<!-- GD Version 2.X Detected -->';
}


This caused the script to malfunction.. I have fixed the script it but I have the same results with the thumbnail being broken.

ThanX folks!

-sk-

RealtyOne
07-09-2003, 10:35 PM
It seems the thumb is created . Can we get a print/echo in the area of the file move? possible it is not being moved? Since this is the only time this has happened to date this is all guess work but we are looking at it.

Anonymous
07-09-2003, 10:47 PM
FYI:

On my test-server at home (PHP 4.3.0, APACHE 2.0.43) everything is running great regarding the thumbnails..

Take a look at this from the author of GD:

http://www.boutell.com/gd/phppatch.html

Now, the real question: How do I get OLM.net to upgrade their server(s)?

ThanX!

-sk-

greengiant
07-10-2003, 07:39 AM
Well, i know what the problem is i just have to figure out where and how to correct it. Acording to the debug info i put in that thumbnail_gd file you put on your server, it thinks you have gd 2.0 installed, but really you are running a 1.6+ version.... THe GD version lookup is failing at some point..

greengiant
07-10-2003, 07:44 AM
Put this script on your server and let me know when it is up, this should tell me where it is detecting the wrgon gd version.



<?php
function make_thumb &#40;$input_file_name, $input_file_path&#41;
&#123;
// makes a thumbnail using the GD library
global $config;

$quality = 100; // jpeg quality -- the lower the num, the smaller the file size

// first, grab the dimensions of the pic
$imagedata = GetImageSize&#40;"$input_file_path/$input_file_name"&#41;;
$imagewidth = $imagedata&#91;0&#93;;
$imageheight = $imagedata&#91;1&#93;;
$imagetype = $imagedata&#91;2&#93;;
// type definitions
// 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP
// 7 = TIFF&#40;intel byte order&#41;, 8 = TIFF&#40;motorola byte order&#41;
// 9 = JPC, 10 = JP2, 11 = JPX
$thumb_name = $input_file_name; //by default
// the GD library, which this uses, can only resize JPG and PNG
if &#40;$imagetype == 2&#41;
&#123;
// it's a JPG
// figure out the ratio to which it should be shrunk, if at all
$shrinkage = 1;
if &#40;$imagewidth > $config&#91;thumbnail_width&#93;&#41;
&#123;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
&#125;
$dest_height = $shrinkage * $imageheight;
$dest_width = $config&#91;thumbnail_width&#93;;

$src_img = imagecreatefromjpeg&#40;"$input_file_path/$input_file_name"&#41;;
///* old function
//GD Lib is Version 2 or >
//$dst_img = imagecreatetruecolor&#40;$dest_width,$dest_height&#41;;
//imagecopyresampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
//GD Lib is Version <2
//$dst_img = imagecreate&#40;$dest_width,$dest_height&#41;;
//imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
//New Function checks to see if GD2 functions are available for higher quality thumbnails
$gdversion2 = sysB_chkgd2&#40;&#41;;
if &#40;!$gdversion2&#41;
&#123;
echo '<!-- GD Version 1.X Detected -->';
&#125;
else
&#123;
echo '<!-- GD Version 2.X Detected -->';
&#125;
if &#40;!$gdversion2&#41;
&#123;
$dst_img = imageCreate&#40;$dest_width, $dest_height&#41;;
&#125;
else
&#123;
$dst_img = imageCreateTrueColor&#40;$dest_width, $dest_height&#41;;
&#125;
//copy the original image info into the new image with new dimensions
//checking to see which function is available
if &#40;!$gdversion2&#41;
&#123;
ImageCopyResized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight&#41;;
&#125;
else
&#123;
ImageCopyResampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight&#41;;
&#125;
$thumb_name = "thumb_"."$input_file_name";
imagejpeg&#40;$dst_img, "$input_file_path/$thumb_name", $quality&#41;;
imagedestroy&#40;$src_img&#41;;
imagedestroy&#40;$dst_img&#41;;
&#125; // end if $imagetype == 2
elseif &#40;$imagetype == 3&#41;
&#123;
// it's a PNG
// figure out the ratio to which it should be shrunk, if at all
$shrinkage = 1;
if &#40;$imagewidth > $config&#91;thumbnail_width&#93;&#41;
&#123;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
&#125;
$dest_height = $shrinkage * $imageheight;
$dest_width = $config&#91;thumbnail_width&#93;;

$src_img = imagecreatefrompng&#40;"$input_file_path/$input_file_name"&#41;;
$dst_img = imagecreate&#40;$dest_width,$dest_height&#41;;
imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
$thumb_name = "thumb_"."$input_file_name";
imagepng&#40;$dst_img, "$input_file_path/$thumb_name"&#41;;
imagedestroy&#40;$src_img&#41;;
imagedestroy&#40;$dst_img&#41;;
&#125; // end if $imagetype == 3


return $thumb_name;
&#125; // end function make_thumb
function sysB_chkgd2&#40;&#41;
&#123;
global $config;
$rep=false;
if&#40;isset&#40;$GLOBALS&#91;"gBGDVersion"&#93;&#41;&#41;
&#123;
$rep=$GLOBALS&#91;"gBGDVersion"&#93;;
echo "<!-- gBGDVersion = $rep -->";
&#125;
else
&#123;
if&#40;function_exists&#40;"gd_info"&#41;&#41;
&#123;
$gdver=gd_info&#40;&#41;;
if&#40;strstr&#40;$gdver&#91;"GD Version"&#93;,"1."&#41;!=false&#41;
&#123;
$rep=false;
echo "<!-- GD Version 1. test = $rep -->";
&#125;
else
&#123;
$rep=true;
echo "<!-- GD Version 1. test = $rep -->";
&#125;
&#125;
else
&#123;
$size =40;
$b=imagettfbbox &#40;$size,0,$config&#91;basepath&#93;.'/include/font/Dustismo.ttf',"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ"&#41;;

if&#40;&#40;$size+1&#41;<abs&#40;$b&#91;5&#93;-$b&#91;3&#93;&#41;&#41;
&#123;
$rep=true;
echo "<!-- imagegettfbbox test = $rep -->";
&#125;
&#125;
$GLOBALS&#91;"gBGDVersion"&#93;=$rep;
&#125;
return $rep;
&#125;
?>

Anonymous
07-10-2003, 08:55 AM
O.K. Done..


The folks at OLM tell me that they are running v1.8.4 rel4 of GD if that is any help..


ThanX

-sk-

greengiant
07-10-2003, 10:27 AM
Try this out...



<?php
function make_thumb &#40;$input_file_name, $input_file_path&#41;
&#123;
// makes a thumbnail using the GD library
global $config;

$quality = 100; // jpeg quality -- the lower the num, the smaller the file size

// first, grab the dimensions of the pic
$imagedata = GetImageSize&#40;"$input_file_path/$input_file_name"&#41;;
$imagewidth = $imagedata&#91;0&#93;;
$imageheight = $imagedata&#91;1&#93;;
$imagetype = $imagedata&#91;2&#93;;
// type definitions
// 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP
// 7 = TIFF&#40;intel byte order&#41;, 8 = TIFF&#40;motorola byte order&#41;
// 9 = JPC, 10 = JP2, 11 = JPX
$thumb_name = $input_file_name; //by default
// the GD library, which this uses, can only resize JPG and PNG
if &#40;$imagetype == 2&#41;
&#123;
// it's a JPG
// figure out the ratio to which it should be shrunk, if at all
$shrinkage = 1;
if &#40;$imagewidth > $config&#91;thumbnail_width&#93;&#41;
&#123;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
&#125;
$dest_height = $shrinkage * $imageheight;
$dest_width = $config&#91;thumbnail_width&#93;;

$src_img = imagecreatefromjpeg&#40;"$input_file_path/$input_file_name"&#41;;
///* old function
//GD Lib is Version 2 or >
//$dst_img = imagecreatetruecolor&#40;$dest_width,$dest_height&#41;;
//imagecopyresampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
//GD Lib is Version <2
//$dst_img = imagecreate&#40;$dest_width,$dest_height&#41;;
//imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
//New Function checks to see if GD2 functions are available for higher quality thumbnails
$gdversion2 = sysB_chkgd2&#40;&#41;;
if &#40;!$gdversion2&#41;
&#123;
echo '<!-- GD Version 1.X Detected -->';
&#125;
else
&#123;
echo '<!-- GD Version 2.X Detected -->';
&#125;
if &#40;!$gdversion2&#41;
&#123;
$dst_img = imageCreate&#40;$dest_width, $dest_height&#41;;
&#125;
else
&#123;
$dst_img = imageCreateTrueColor&#40;$dest_width, $dest_height&#41;;
&#125;
//copy the original image info into the new image with new dimensions
//checking to see which function is available
if &#40;!$gdversion2&#41;
&#123;
ImageCopyResized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight&#41;;
&#125;
else
&#123;
ImageCopyResampled&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $imagewidth, $imageheight&#41;;
&#125;
$thumb_name = "thumb_"."$input_file_name";
imagejpeg&#40;$dst_img, "$input_file_path/$thumb_name", $quality&#41;;
imagedestroy&#40;$src_img&#41;;
imagedestroy&#40;$dst_img&#41;;
&#125; // end if $imagetype == 2
elseif &#40;$imagetype == 3&#41;
&#123;
// it's a PNG
// figure out the ratio to which it should be shrunk, if at all
$shrinkage = 1;
if &#40;$imagewidth > $config&#91;thumbnail_width&#93;&#41;
&#123;
$shrinkage = $config&#91;thumbnail_width&#93;/$imagewidth;
&#125;
$dest_height = $shrinkage * $imageheight;
$dest_width = $config&#91;thumbnail_width&#93;;

$src_img = imagecreatefrompng&#40;"$input_file_path/$input_file_name"&#41;;
$dst_img = imagecreate&#40;$dest_width,$dest_height&#41;;
imagecopyresized&#40;$dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight&#41;;
$thumb_name = "thumb_"."$input_file_name";
imagepng&#40;$dst_img, "$input_file_path/$thumb_name"&#41;;
imagedestroy&#40;$src_img&#41;;
imagedestroy&#40;$dst_img&#41;;
&#125; // end if $imagetype == 3


return $thumb_name;
&#125; // end function make_thumb
function sysB_chkgd2&#40;&#41;
&#123;
global $config;
$rep=false;
if&#40;isset&#40;$GLOBALS&#91;"gBGDVersion"&#93;&#41;&#41;
&#123;
$rep=$GLOBALS&#91;"gBGDVersion"&#93;;
echo "<!-- gBGDVersion = $rep -->";
&#125;
else
&#123;
if&#40;function_exists&#40;"gd_info"&#41;&#41;
&#123;
$gdver=gd_info&#40;&#41;;
if&#40;strstr&#40;$gdver&#91;"GD Version"&#93;,"1."&#41;!=false&#41;
&#123;
$rep=false;
echo "<!-- GD Version 1. test = $rep -->";
&#125;
else
&#123;
$rep=true;
echo "<!-- GD Version 1. test = $rep -->";
&#125;
&#125;
else
&#123;
@imagecopyresampled&#40;&#41;;
if &#40;$php_errormsg != "imagecopyresampled&#40;&#41;&#58; requires GD 2.0 or later"&#41;
&#123;
$rep=true;
echo "<!-- imagecopyresampled test = $rep -->";
&#125;
else
&#123;
$rep=false;
echo "<!-- imagecopyresampled test = $rep -->";
&#125;
&#125;
$GLOBALS&#91;"gBGDVersion"&#93;=$rep;
&#125;
return $rep;
&#125;
?>

Anonymous
07-10-2003, 11:01 AM
O.K. done...

-sk-

Anonymous
07-10-2003, 07:49 PM
Well, the new beta 11 code seems to have done the trick. Hard-coding the GD version in "common.php" definitely did the trick. I'm glad you did it before I tried to...

It's a bummer that PHP 4.2.3 has a broken embedded version of the GD library. And with no 'gd_info()' staement available until V 4.3 you're really screwed when the only way to get a GD version# is incorrect...

Thanks for all the help folks!

-sk-