1

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?

Tolgay Toklar
  • 4,151
  • 8
  • 43
  • 73

2 Answers2

0

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 );
?>
Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
0

Check error log or do

print_r(error_get_last());

to get more information, GD might use E_NOTICE error level to pass more information on the issue

MattJ
  • 1
  • 1