[image processing] PHPWebGallery chrashes when trying to load large files (Fix included) #63

Closed
opened 2026-10-04 23:42:03 +02:00 by adam · 2 comments
Owner

Reported by linuxlefty on 13 Apr 2008 08:35

Version: 1.7.1

When trying to load large files that require more memory that is currently allocated to PHP, PHPWebGallery simply gives a blank page instead of giving some kind of useful information.

Steps to reproduce: 1) Load a file that requires more memory than PHP has available. Note that this doesn't have to be a large-sized file. Although the size is well below the memory limit, if the dimensions or resolution is high, it will gobble up a lot of memory.

  1. Attempt to create a thumbnail of the file

  2. You are greeted with a blank screen and confused user

Additional information: When I first hit this error, I just gave up on PhpWebGallery and tried a different piece of software. However, I really liked PhpWebGallery so I came back to it and found the root of the problem.

In admin/thumbnail.php, apply the following patch:

50,63d49
< $imageInfo = getimagesize($path);
< $memoryNeeded = round(
< (
< $imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + 65536 ) /* memory needed /
< * 1.5 /
fudge factor _/
< / (1024_1024) /* convert from bytes => MB */
< );
< $memoryAvialable = substr( ini_get('memory_limit'), 0, -1 );
<
< if ( $memoryNeeded > $memoryAvialable )
< {
< echo ("ERROR: Unable to create thumbnail of $path. Image requires too much memory.<br />");
< return;
< }

basically, it calculates the needed memory and alerts the user if there won't be enough memory available.

Piwigo Bugtracker #820

**Reported by linuxlefty on 13 Apr 2008 08:35** **Version:** 1.7.1 When trying to load large files that require more memory that is currently allocated to PHP, PHPWebGallery simply gives a blank page instead of giving some kind of useful information. **Steps to reproduce:** 1) Load a file that requires more memory than PHP has available. Note that this doesn&#039;t have to be a large-sized file. Although the size is well below the memory limit, if the dimensions or resolution is high, it will gobble up a lot of memory. 2) Attempt to create a thumbnail of the file 3) You are greeted with a blank screen and confused user **Additional information:** When I first hit this error, I just gave up on PhpWebGallery and tried a different piece of software. However, I really liked PhpWebGallery so I came back to it and found the root of the problem. In admin/thumbnail.php, apply the following patch: 50,63d49 &lt; $imageInfo = getimagesize($path); &lt; $memoryNeeded = round( &lt; ( &lt; $imageInfo[0] \* $imageInfo[1] \* $imageInfo[&#039;bits&#039;] \* $imageInfo[&#039;channels&#039;] / 8 + 65536 ) /\* memory needed _/ &lt; \* 1.5 /_ fudge factor _/ &lt; / (1024_1024) /\* convert from bytes =&gt; MB */ &lt; ); &lt; $memoryAvialable = substr( ini_get(&#039;memory_limit&#039;), 0, -1 ); &lt; &lt; if ( $memoryNeeded &gt; $memoryAvialable ) &lt; { &lt; echo (&quot;ERROR: Unable to create thumbnail of $path. Image requires too much memory.&lt;br /&gt;&quot;); &lt; return; &lt; } basically, it calculates the needed memory and alerts the user if there won&#039;t be enough memory available. [Piwigo Bugtracker #820](http://piwigo.org/bugs/view.php?id=820) <!-- github-sync-id:97225501 -->
adam closed this issue 2026-10-04 23:42:03 +02:00
Author
Owner

Comment posted by linuxlefty on 13 Apr 2008 11:15

I forgot to add, the code is based off of comments I read at: http://cn2.php.net/imagecreatefromjpeg

**Comment posted by linuxlefty on 13 Apr 2008 11:15** I forgot to add, the code is based off of comments I read at: http://cn2.php.net/imagecreatefromjpeg <!-- github-comment-id:124890715 -->
Author
Owner

Comment posted by VDigital on 31 Mar 2010 19:39

Up! For Piwigo 2.x ???

**Comment posted by VDigital on 31 Mar 2010 19:39** Up! For Piwigo 2.x ??? <!-- github-comment-id:124890747 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#63