An image gallery script that worked with earlier versions of PHP
started generating this message once we upgraded to 4.3.*. --I've tried
installing everything from 4.3.1 to RC2 of 4.3.3, and they all have the
same problem.
Has something changed in the way PHP handles jpegs? Can someone point to
the error in the script below? Any and all help would be appreciated
My php configure options include gd and jpeg libraries:
[
--with-mysql=/etc/mysql --with-xml --with-apache=../apache_1.3.28
--enable-track-vars --with-gd --with-zlib-dir=/usr/local
--with-jpeg-dir=/usr --with-png=/usr/local --with-curl=/usr/local
--with-openssl=/etc/ssl --with-swf=usr/local
]
Also,
<?
var_dump(gd_info());
?>
shows this:
array(10) { ["GD Version"]=> string(27) "bundled (2.0.15 compatible)" ["FreeType Support"]=> bool(false) ["T1Lib Support"]=> bool(false) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(false) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
The part of the script that's causing problems is below:
====================================================
$today=date("dmy");
$image_name = $today . "" . $image_name;
$destination ="./images/" . $image_name;
$thumbnail = "./images/thumb" . $image_name;
$MAX_WIDTH = 175;
$MAX_HEIGHT = 150;
if (is_uploaded_file($HTTP_POST_FILES['image']['tmp_name'])) {
copy($HTTP_POST_FILES['image']['tmp_name'], "./images/" .
$image_name);
} else {
echo "Well, that didn't work";
}
$thumb = ImageCreateFromJPEG($destination);
if (!$thumb) {
echo "oops, didn't work!";
} else {
$size = GetImageSize($destination);
if (($size[0] / $size[1]) > ($MAX_WIDTH / $MAX_HEIGHT))
$modifier = $MAX_WIDTH / $size[0];
else $modifier = $MAX_HEIGHT / $size[1];
$image_copy = @imagecreatefromjpeg ($destination);
$thumbnail_memory = @ImageCreate ($size[0] * $modifier, $size[1] *
$modifier);
imagecopyresized ($thumbnail_memory, $image_copy, 0, 0, 0, 0,
$size[0] $modifier,
$size[1] $modifier, $size[0], $size[1]);
imagejpeg ($thumbnail_memory, $thumbnail);
====================================================
This last line is where the script dies with the error:
imagejpeg(): gd-jpeg: JPEG library reports unrecoverable error