Page 1 of 1

Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 5:31 am
by Terriator
Heya, I have a script which creates and saves an image:

Code: Select all

function  create_image(){
    
        // User data
        $message1 = 'TEXT';
        $message2 = 'TEXT';
        $message3 = 'TEXT';
        $message4 = 'TEXT';
        $message5 = 'TEXT';  
        
            
    $im = imagecreatefromgif("./images/signatures/default1.gif") or die("Cannot Initialize new GD image stream");
    $text = imagecolorallocate($im, 0, 0, 0);      // text colour
    imagestring($im, 2, 10,  23, $message1, $text);
    imagestring($im, 2, 10,  33, $message2, $text);
    imagestring($im, 2, 10,  43, $message3, $text);
    imagestring($im, 2, 10,  53, $message4, $text);
    imagestring($im, 2, 10,  63, $message5, $text);
        
    imagepng($im,"./images/signatures/".$_SESSION['uid'].".png");
    imagedestroy($im);
        
}
Afterwards, when I go to Vbulletin and enter: http://XXX/images/signatures/3819.gif I get following error:
Warning: getimagesize(http://XXX/images/signatures/3819.gif) [function.getimagesize]: failed to open stream: Connection timed out in /profile.php(1189) : eval()'d code on line 10
So, how to fix? =)

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 5:35 am
by VladSun
1. Use local file "address" instead of http://XXX/images/signatures/3819.gif:
I mean:
getimagesize('./images/signatures//3819.gif');

2. You generate PNG files and then you try to read GIF files ...

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:02 am
by Terriator
1. It's supposed to be an image that people can use on any forum; so it wouldn't work with a local address? Or am I stupid?

2. Sorry about that; because I tried out both the png and the gif function.

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:09 am
by VladSun
Perhaps your server firewall (the one with Vbulletin) doesn't allow outgoing connections.
Can you open http://XXX/images/signatures/3819.gif from your browser?

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:28 am
by Terriator
Yep, works fine.. it's only the getimagesize function that doesn't like the image it seems.

Actually, it seems like it's not something related to the script perhaps, because any images I upload and try to view in my forum gets a timeout.

However, when I try to load the same images in different forums (this one, for example), it works fine ~___~

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:37 am
by VladSun
It could happen if your forum is running on a DMZ server - i.e. you have a router which will forward all requests from Internet to your server. But it doesn't happen when a request on its internal interface is received. And this is the case when you try to open http://domain.com, because the resolved IP is actuallly the IP of the router.

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:41 am
by Terriator
In other words: I modify my own forum's way of showing the images and it should then work on all others? (which I should of course check)

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:45 am
by VladSun
I don't know what's your case but try replacing in your forum http://XXX/ with http://localhost/ and see if it works.

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:50 am
by Terriator
Nope, doesn't..

Re: Getimagesize and imagepng()

Posted: Mon Feb 09, 2009 6:57 am
by VladSun
Terriator wrote:Nope, doesn't..
So, now you should have:
Warning: getimagesize(http://localhost/images/signatures/3819.gif) [function.getimagesize]: failed to open stream: Connection timed out in /profile.php(1189) : eval()'d code on line 10
error?