I've been getting this error:
Code: Select all
recoverable error: imagecreatefromjpeg() : gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file on line 18The problem is this:
A) There are over 7000 images, so I can't change them by hand.
B) I don't want to pay for image correction software.
I've got
PHP Version 5.2.0RC2-dev
GD (2.0.28 compatible)
Apache/2.2.2 (Win32)
I also have gd.jpeg_ignore_warning set to 1, and uncommented in php.ini
Code: Select all
<?php
header('Content-type: image/jpeg');
$file = $_GET['imagename'];
$maxheight= $_GET['maxheight'];
list($width, $height) = getimagesize($file);
if(is_numeric($maxheight))
{
$ratio = $maxheight / $height;
}
else
{
$ratio = 1;
}
$modwidth = $width * $ratio;
$modheight = $height * $ratio;
$tn= imagecreatetruecolor($modwidth, $modheight);
$source = imagecreatefromjpeg($file);
imagecopyresampled($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn);
?>