This code returns false:
$image = imagecreatefromjpeg("photos/profiles/original/4cdf149b63d0ca0158f68357d8da371c_y.jpg");
var_dump($image);
exit;
But this code:
$image = getimagesize("photos/profiles/original/4cdf149b63d0ca0158f68357d8da371c_y.jpg");
var_dump($image);
exit;
Returns this:
array(7) { [0]=> int(2576) [1]=> int(1932) [2]=> int(2) [3]=> string(26) "width="2576" height="1932"" ["bits"]=> int(8) ["channels"]=> int(3) ["mime"]=> string(10) "image/jpeg" }
Also i can see the photo from any web browsers or something etc. How can i fix this problem?
A combination of gd.jpeg_ignore_warning
and using the @
to suppress the error mentioned in the comment appears to work but for some inexplicable reason rotates the image by 90 degrees ~ perhaps the image was taken on a mobile?
<?php
ini_set ('gd.jpeg_ignore_warning', 1);
$src='c:/temp2/4cdf149b63d0ca0158f68357d8da371c_y.jpg';
$img=@imagecreatefromjpeg( $src );
header( 'Content-Type: image/jpeg' );
imagejpeg( $img );
imagedestroy( $img );
?>