I am using the imagecreatefromjpeg() function to upload images via an upload form:
$folder = '../images/';
$image = imagecreatefromjpeg($_FILES['image']['tmp_name']);
$new = imagecreatetruecolor(300, 300);
imagecopyresampled($new, $image, 0, 0, 0, 0, 300, 300, 150, 150);
imagejpeg($new, $folder, 100);
Most photos upload fine but some display this error:
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 756 extraneous bytes before marker 0xed
It seems to occur with some, but not all, '.jpeg' files. I have not seen the problem occur with '.jpg' files, but I cannot be certain that the problem is exclusive to '.jpeg' files. I did notice that if I change the extension on the problem file from '.jpeg' to '.jpg', it works just fine.
Why do I get "Corrupt JPEG data" message when using imagecreatefromjpeg() function in php?