iPhones shoot HEIC by default — roughly half the size of an equivalent JPEG — but Chrome and Firefox cannot render the format. Until recently, Laravel's image component rejected HEIC files before they reached the driver. Laravel 13.24 changes that: it accepts HEIC, HEIF and AVIF as inputs, adds toHeic() for output, and teaches the image validation rule about all three formats. The HEIC/AVIF support was contributed by @riasvdv in PR #60922.
On the server side, HEIC decoding requires the Imagick extension built with ImageMagick's HEIF delegate (based on libheif); GD cannot read HEIC at all. Many distro packages ship ImageMagick without that delegate, so verify with php -r "print_r(Imagick::queryFormats('HEI*'));" — an empty array means the extension cannot handle these files. On Debian/Ubuntu the delegate lives in libheif1; Homebrew's imagemagick formula includes it. AVIF is easier, since GD can decode it when PHP is built against libavif. Intervention Image (^4.0) backs both drivers.
Validation needs no configuration: the image rule now recognizes heic, heif and avif, so a straight iPhone camera-roll upload passes where it previously failed. The mimes rule (e.g. mimes:jpg,png,webp,heic) works too, and both rules resolve the type from file contents rather than the browser-reported MIME type, which for HEIC varies between image/heic, image/heif and others.
Because browsers cannot display stored HEIC, conversion should happen during upload: $request->image('photo')->usingImagick()->orient()->scale(width: 2000)->toWebp()->quality(80)->store('photos'). usingImagick() is required since the default GD driver fails on HEIC, and orient() applies the rotation metadata common in phone photos. store() generates a hashed filename with the correct extension, so a converted upload lands as photos/{hash}.webp.
To serve AVIF with a WebP fallback, branch from a single prepared source — each transformation returns a new instance, so no state leaks — then store both variants and let the browser choose via a <picture> element with an AVIF <source>. AVIF is typically 20–30% smaller than WebP at comparable quality but encodes more slowly, which makes synchronous conversion a candidate for a queued job once multiple sizes are generated.
Writing HEIC is also possible via toHeic() or optimize('heic'), useful for archives or exports targeting Apple devices. The heif alias is normalized to HEIC throughout: files are stored with the canonical .heic extension and mimeType() reports image/heic. Image::extension() also maps the image/x-heic and image/x-avif aliases correctly.
Unsupported formats reaching the driver raise an ImageException naming the offending type (e.g. "The image format [image/tiff] is not supported."). The same exception appears when HEIC hits an Imagick build without the HEIF delegate — a deployment issue best caught by checking the delegate during release. For Laravel versions before 13.24, the article points to a separate guide on manual HEIC-to-JPEG conversion in PHP.
Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.