JPG Thumbnail / imagecreatefromjpeg / GD Problems

Please post all install related problems here. Visit this forum first for troubleshooting.
Post Reply
kismert
Posts: 6
Joined: Wed 21. Mar 2007, 17:15

JPG Thumbnail / imagecreatefromjpeg / GD Problems

Post by kismert »

Hi, all:

I have a site that works fine on my local WAMP stack, but fails on a remote LAMP stack. Thumbnails of JPG files are the issue.

The thumbnails don't generate on the LAMP stack. I can't edit articles because display of article elements stops if it contains an image without a thumbnail. I can't insert images in an article, because the pop-up folder list doesn't show images without thumbnails.

I traced the issue to /include/inc_ext/ss_image/ss_image.class.php, around line 89:

Code: Select all

			case "2"://JPEG
			$this->img_original = imagecreatefromjpeg($src);
			break;
The imagecreatefromjpeg() function crashes the script. This is responsible for both the article and folder list failures.

The odd thing is, when I use a stand-alone php test script using the functions imagecreatefromjpeg() and imagejpeg(), both the WAMP and the LAMP servers work perfectly! I can create images, and save them to the /filearchive directory on both of them.

The particulars:

My WAMP phpinfo():
  • PHP Version: 5.1.4
    Configure Command: "--with-gd=shared"
    GD Support: enabled
    GD Version: bundled (2.0.28 compatible)
    JPG Support: enabled
My LAMP phpinfo():
  • PHP Version: 4.3.9
    Configure Command: '--with-gd=shared' '--enable-gd-native-ttf' '--without-gdbm'
    GD Support: enabled
    GD Version: bundled (2.0.28 compatible)
    JPG Support: enabled
So, what's going on? Any ideas?

Thanks,

-Ken
Last edited by kismert on Thu 26. Apr 2007, 10:34, edited 1 time in total.
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

Which version is the WAMP phpinfo() ?
In PHP
In PHP 5.1.4+...you might could try editing "php.ini" for the failing server (as an experiment):

php.ini directive:

Code: Select all

gd.jpeg_ignore_warning = 1
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Check how large your JPG is when it is opened. Maybe your remote LAMP has low memory settings.

What error message do you get?

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
kismert
Posts: 6
Joined: Wed 21. Mar 2007, 17:15

Post by kismert »

DeXXus,

Oops, typo! To clarify:

WAMP: PHP 5.1.4 -- OK

LAMP: PHP 4.3.9 -- Fails when generating thumbnails, but works in stand-alone test script.

Does the gd.jpeg_ignore_warning work only for PHP 5.1.4+ ?

Oliver,

I get no warnings or error messages. The script just terminates in ss_image.class.php.

The original JPG images are all <= 2MB.

LAMP (PHP 4.3.9) memory details:
  • Configure Command: '--enable-memory-limit'
    memory_limit: 8M
8MB seems a little low, maybe?

Thanks,
-Ken
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

kismert wrote:DeXXus,

Oops, typo! To clarify:

WAMP: PHP 5.1.4 -- OK

LAMP: PHP 4.3.9 -- Fails when generating thumbnails, but works in stand-alone test script.

Does the gd.jpeg_ignore_warning work only for PHP 5.1.4+ ?
Thanks,
-Ken
Yes, it is ONLY present in 5.1.4 and UP... so forget that. :?
To prove any memory limitation issue you could try a small size JPG for thumbnail creation to see if it fails too.
And as OliverG has explained many times... YES the compression of an original image DOES trigger much larger amounts of memory resource usage while handling those large images!
kismert
Posts: 6
Joined: Wed 21. Mar 2007, 17:15

Solved!

Post by kismert »

I found the solution:

The PHPWCMS files did not have proper ownership. To fix this, I had to change ownership to the Apache user. This is generic advice for any PHP application that needs to create/modify files:
  • 1. Determine the user the Apache service runs under. On our server, it is 'nobody'
    2. Go to the parent directory of your PHPWCMS installation.
    3. Issue the command: chown -R <apacheUser> <phpwcmsDirectory>
Once done, you should have no trouble uploading files, and inserting them into content.

Of course, the confusing thing was that the GD imagecreatefromjpeg() call in ss_image.class.php just failed silently, terminating with no error message. It gave no indication that it was a permissions problem.

Suggestion: Does the GD library generate exceptions? If so, ss_image.class.php could trap those exceptions and give a more meaningful error message.

Thanks,
-Ken
Post Reply