Page 1 of 10

It was not possible to determine the dimensions of the image

Posted: Sun Jun 10, 2007 5:53 am
by monotek
I use PHPBB3 RC1. I configured max image size to 800*600 in acp.

If i try to post a image to a thread or to a private message using bbcode [img] i get the following error message:
It was not possible to determine the dimensions of the image.
PHP function getimagesize() works fine if i test with:

Code: Select all

<?php
$info = getimagesize("image.jpg");
foreach($info as $key => $value) {
    echo $key . ' - ' . $value . '<br />';
}
?>
I get this output:
0 - 83
1 - 90
2 - 2
3 - width="83" height="90"
bits - 8
channels - 3
mime - image/jpeg
What to do to get this work?

Re: It was not possible to determine the dimensions of the image

Posted: Sun Jun 10, 2007 6:03 am
by karlsemple
If the functions is definitely working on the host you might want to submit this to the bug tracker as it might be a bug :)

Re: It was not possible to determine the dimensions of the image

Posted: Sun Jun 10, 2007 6:31 am
by monotek
I thinks its something with my server configuration, because it works here.

:arrow: Image

I also tried to activate allow_url_fopen an shutting down my firewall but the error remains...

Re: It was not possible to determine the dimensions of the image

Posted: Sun Jun 10, 2007 6:35 am
by karlsemple
You know you tested the getimagesize() functions......did you test it on images on the host.... maybe the host has blocked it from working with external sources..guessing here of course

for example

Code: Select all

<?php

$info = getimagesize('http://www.google.de/intl/de_de/images/logo.gif');

foreach ($info as $key => $value)
{
	echo $value."<br />";
}

>
does that work for you?

Re: It was not possible to determine the dimensions of the image

Posted: Sun Jun 10, 2007 7:17 am
by monotek
I solved the Problem :-)

allow_url_fopen was disabled 2 times in php.ini.

First with "disable_functions allow_url_fopen" and then a second time with "allow_url_fopen Off".

After editing both appearances it works. Unfortunately i also have to disable my firewall to get this work.

Therefore i would prefer to check the image size by java script on the client like in my old board...

Re: It was not possible to determine the dimensions of the image

Posted: Sat Jun 16, 2007 8:04 am
by Flai
karlsemple wrote:You know you tested the getimagesize() functions......did you test it on images on the host.... maybe the host has blocked it from working with external sources..guessing here of course

for example

Code: Select all

<?php

$info = getimagesize('http://www.google.de/intl/de_de/images/logo.gif');

foreach ($info as $key => $value)
{
	echo $value."<br />";
}

>
does that work for you?
I have the same problem and tested your script. The output is:

Code: Select all

301
110
1
width="301" height="110"
8
3
image/gif
My server runs with PHP Version 4.4.0 and phpinfo says allow_url_fopen=On.

:(

Re: It was not possible to determine the dimensions of the image

Posted: Wed Jun 20, 2007 12:07 pm
by hryst
Hello,

I have the same problem with my forum hosted by Dreamhost, caused by switched off attrib "allow_url_fopen". Unfortunatelly, there is no easy way to turn this on.
The function "getimagesize" runs correctly with local files (see: http://www.armedassault.com.pl/test2.php) but can not open a file from other URL.

This error causes that on my forum there is no possibility to view avatars and other new added graphics correctly.

Re: It was not possible to determine the dimensions of the image

Posted: Wed Jun 20, 2007 3:17 pm
by monotek
Just turn off the image size check...

Re: It was not possible to determine the dimensions of the image

Posted: Thu Jun 21, 2007 8:34 am
by hryst
It is no solution

Re: It was not possible to determine the dimensions of the image

Posted: Wed Jun 27, 2007 5:47 am
by Jhong
Many servers have allow_url_fopen switched off.

A quick workaround is to use cURL to fetch the image and check the size. The mod is as follows:

OPEN: /includes/message_parser.php

FIND:

Code: Select all

			if ($stats === false)
			{
AFTER, ADD:

Code: Select all

				if (function_exists('curl_exec'))
				{
					$c_img = curl_init();
					$c_timeout = 8; //The timeout, in seconds. You may want to change this
					$c_max_filesize = 64000; //The max file size loaded into memory
					curl_setopt($c_img, CURLOPT_URL, $in);
					curl_setopt($c_img, CURLOPT_RETURNTRANSFER, 1);
					@curl_setopt($c_img, CURLOPT_BUFFERSIZE, $c_max_filesize);
					curl_setopt($c_img, CURLOPT_CONNECTTIMEOUT, $c_timeout);
					curl_setopt($c_img, CURLOPT_FOLLOWLOCATION,1);
					$grabbed_img = @curl_exec($c_img);
					curl_close($c_img); 
					$stats[0] = $stats[1] = false;
					if ($grabbed_img)
					{
						$grabbed_img = @imagecreatefromstring($grabbed_img);
						$stats[1] = @imagesx($grabbed_img);
						$stats[0]= @imagesy($grabbed_img);
						unset($grabbed_img, $c_img);
					}
					if (!$stats[0] || !$stats[1])
					{
						$stats = false;
					}
				}
			}
			if ($stats === false)
			{			
Save the file, and the problem should go away. I've tried hard to choose settings in order to prevent the server loading ahuge image into memory by accident, but it may need some tweaking.

Re: It was not possible to determine the dimensions of the image

Posted: Wed Jun 27, 2007 3:09 pm
by cyfr
Ive tried what you said but I get parse error when I try and put an image in sig.

At the moment all that works is removing restrictions on size. I dont like this as people could use HUGE images.

Any other workarounds? :cry:

Re: It was not possible to determine the dimensions of the image

Posted: Wed Jun 27, 2007 11:45 pm
by emeraldisle
I had this problem as well. After reading this thread though I went into the php.ini file that my server uses. I downloaded it and opened it with notepad. I changed where it had:

allow_url_fopen = off

to

allow_url_fopen = on

Saved and uploaded and that fixed the problem.

Hope this helps others.

Emeraldisle

Re: It was not possible to determine the dimensions of the image

Posted: Thu Jun 28, 2007 12:37 am
by cyfr
I use dreamhost and I dont think its possible for me to change the php.ini so is there any other way? :(

Re: It was not possible to determine the dimensions of the image

Posted: Thu Jun 28, 2007 12:45 pm
by cyfr
Still got this problem, really annoying! :(

Re: It was not possible to determine the dimensions of the image

Posted: Wed Jul 04, 2007 11:20 pm
by monotek
Jhong wrote:Many servers have allow_url_fopen switched off.

A quick workaround is to use cURL to fetch the image and check the size. The mod is as follows:

OPEN: /includes/message_parser.php

FIND:

Code: Select all

			if ($stats === false)
			{
AFTER, ADD:

Code: Select all

				if (function_exists('curl_exec'))
				{
					$c_img = curl_init();
					$c_timeout = 8; //The timeout, in seconds. You may want to change this
					$c_max_filesize = 64000; //The max file size loaded into memory
					curl_setopt($c_img, CURLOPT_URL, $in);
					curl_setopt($c_img, CURLOPT_RETURNTRANSFER, 1);
					@curl_setopt($c_img, CURLOPT_BUFFERSIZE, $c_max_filesize);
					curl_setopt($c_img, CURLOPT_CONNECTTIMEOUT, $c_timeout);
					curl_setopt($c_img, CURLOPT_FOLLOWLOCATION,1);
					$grabbed_img = @curl_exec($c_img);
					curl_close($c_img); 
					$stats[0] = $stats[1] = false;
					if ($grabbed_img)
					{
						$grabbed_img = @imagecreatefromstring($grabbed_img);
						$stats[1] = @imagesx($grabbed_img);
						$stats[0]= @imagesy($grabbed_img);
						unset($grabbed_img, $c_img);
					}
					if (!$stats[0] || !$stats[1])
					{
						$stats = false;
					}
				}
			}
			if ($stats === false)
			{			
Save the file, and the problem should go away. I've tried hard to choose settings in order to prevent the server loading ahuge image into memory by accident, but it may need some tweaking.
Nice. Maybe this is a workaround for a lot of peaople. Please add this patch to the bugtracker. Maybe its implemeted in phpbb3 final :-)