3

After checked about 20 solutions I gave up and need help. I've got 2 JPG files. Both have proper mime, they are not too big for upload_max_filesize, names are ok, path is ok. Every solution was about one of those issues.

My problem is when I run script on first image it is ok, no error, object is created:

$image1 = Image::make(public_path()."/uploads/goodimage.jpg");

See example: https://app.esticrm.pl/uploads/goodimage.jpg

When I run it on other picture I'm getting error:

$image2 = Image::make(public_path()."/uploads/badimage.jpg");

See example: https://app.esticrm.pl/uploads/badimage.jpg

Error message:

Intervention \ Image \ Exception \ NotReadableException Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files.

Same situation on Windows and Linux. Files are opening on every graphic program and browser I've checked. Those problems has started after PHP upgrade from 5.5.x to 5.6.35. Was fine before.

5
  • dd(public_path()."/uploads/goodimage.jpg") Sep 24, 2018 at 20:33
  • What type of frame do the JPEG stream use? Sep 26, 2018 at 4:22
  • @user3344003 you mean GD or imagick? Like in error, GD.
    – wesol3d
    Sep 27, 2018 at 6:16
  • Sequential, Baseline, or Progressive, or something else. Sep 27, 2018 at 21:00
  • Every user of my webapp creates and uploads JPEG, I won't tell them how to store pictures. It supposed to store every type of stream, as it does in 5.5.x. After PHP update, it does not, and I'm looking for solution.
    – wesol3d
    Sep 28, 2018 at 21:28

5 Answers 5

3

Ok, I found solution:

$image2 = Image::make(file_get_contents(public_path()."/uploads/badimage.jpg"));

Works also on file object from form:

$image2 = Image::make(file_get_contents(Input::file('upload_file'));
1

I had the same problem and my way of solving was the next. I had to change the size that nginx allowed the user to upload in /etc/nginx.conf, like this:

 http {
    client_max_body_size 100M;
 }

And I had to change also my php.ini, to increase the size of the files uploaded and the total size:

upload_max_filesize = 4M
post_max_size = 16M

I hope helps someone

1

change following variables in php.ini file

post_max_size = 128M
upload_max_filesize = 128M

print phpinfo() to find your php.ini location.

If its cpanel its under software section->php versions-> click on "Switch To PHP Options" . Then change the value. Also change the max_execution_time to 600

0

if you are downloading remote image and use it with Image::, make sure that image is downloaded correctly. Sometimes when you are using file_get_contens(), image will not be downloaded or it will have size 0. So better way to download remote image is to use CURL, but in this case you have to be sure that remote url is https

 $content = $this->url_get_contents(str_replace('http://','https://',$remote_img_path));

where url_get_contents() is curl to get remote image as explained on floyk.com: https://floyk.com/en/post/laravel-unsupported-image-type-gd-driver-is-only-able-to-decode-jpg-png-gif-or-webp-files

0

The error message "Unsupported image type image/tiff" means that the GD library being used by the Intervention Image library does not support TIFF images. The GD library is a graphics library for PHP that provides image manipulation functionality, and it only supports a limited number of image formats.

To convert a TIFF image to a PNG image, you will need to use a different library or tool that supports TIFF images. One option is to use the Imagick PHP extension, which provides a set of functions for working with images and supports a wider range of image formats, including TIFF.

To use the Imagick extension, you will first need to install it on your server and then update your code to use the Imagick functions instead of the GD functions. Here is an examp…

$imagick = new Imagick();
$imagick->readImage('input.tif');
$imagick->setImageFormat('png');
$imagick->writeImage('output.png');

Alternatively, you could use a command-line tool like ImageMagick to convert the TIFF image to a PNG image. You can then use the PHP exec() function to call the ImageMagick command from your PHP code.

exec('convert input.tif output.png');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.