Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

daugaard47's avatar

Uploading Heic/Heif images

I have users that need to upload images and notice in my error logs many are using the iPhone HEIC/HEIF image format.

Error received:

Intervention\Image\Exception\NotReadableException | PHP 8.1.11
Unsupported image type image/heif. GD driver is only able to decode JPG, PNG, GIF, BMP or WebP files.

I have read to use Imagemagick for this type of support. But I see on Mar. 6th 2021 the LibGD added AVIF & HEIF support.

I updated to PHP 8.1.11 and checked the GD version. Looks like I'm still at version 2.1.0, which is a 2015 version. Maybe I'm incorrect here. It does say, "AVIF Support => enabled". Though it does not say "HEIF Support => enabled"

PHP Info:

gd

GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.9.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 8
PNG Support => enabled
libPNG Version => 1.6.34
WBMP Support => enabled
XPM Support => enabled
libXpm Version => 30512
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
AVIF Support => enabled
TGA Read Support => enabled

Questions:

  1. What are you all using to to support this format?
  2. I'd rather stick with GD since it's already installed, but if I do need to update the version from 2.1.0 to 2.3.+ How can I do this?
  3. If I am using the correct GD version, how can I get HEIF enabled?

Details:

  • OS: Win 11
  • Local Server: Laragon 6 Apache
  • PHP 8.1.11
  • Laravel 9+
  • Livewire: Using this to upload images. Added 'avif ', 'heif', 'heic', 'heif-sequence', 'heic-sequence', to the 'temporary_file_upload' => 'preview_mimes' in the config/livewire.php file.
0 likes
4 replies
kokoshneta's avatar

Apparently, even in PHP 8.1, the bundled version of GD is old and outdated on Windows. It is of course possible to update it, but there seems to be a remarkable dearth of details on how exactly that’s done, particularly for Windows.

Downloading a recent release from the libgd releases page on GitHub gives you a folder with lots of subfolders, including one called Windows, which contains a readme.md file that details how to build the library using Visual Studio, but that’s about all you get. After you do that, it seems you’d also have to rebuild PHP against your newly built GD… I think.

As far as I can tell, there doesn’t seem to be an easy and user-friendly way to simply get the latest version and point PHP to that.

Snapey's avatar

I have been told, but unable to confirm, If you correctly specify the accepted filetypes on the file input field, then apple devices will convert heic to png on the fly so that the heic image never reaches your server.

Please or to participate in this conversation.