Laravel 13.24: Dominant Color, HEIC &amp; More | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Image Dominant Color and HEIC Support in Laravel 13.24        On this page       1. [  Dominant Color Detection ](#dominant-color-detection)
2. [  HEIC and AVIF Input/Output ](#heic-and-avif-inputoutput)
3. [  modelKeys() on the Eloquent Query Builder ](#codemodelkeyscode-on-the-eloquent-query-builder)
4. [  New array\_keys Validation Rule ](#new-codearray-keyscode-validation-rule)
5. [  Wildcard Validation Performance Fix ](#wildcard-validation-performance-fix)
6. [  Key Takeaways ](#key-takeaways)

  ![Image Dominant Color and HEIC Support in Laravel 13.24](https://cdn.msaied.com/514/1db4d7a38103ef4be23345bd39fc7658.png)

 [  Laravel ](https://msaied.com/articles?category=laravel)  #Laravel 13.24   #Image API   #HEIC   #Validation   #Eloquent   #Performance  

 Image Dominant Color and HEIC Support in Laravel 13.24 
========================================================

     4 Aug 2026      4 min read    ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said  

       Table of contents

1. [  01   Dominant Color Detection  ](#dominant-color-detection)
2. [  02   HEIC and AVIF Input/Output  ](#heic-and-avif-inputoutput)
3. [  03   modelKeys() on the Eloquent Query Builder  ](#codemodelkeyscode-on-the-eloquent-query-builder)
4. [  04   New array\_keys Validation Rule  ](#new-codearray-keyscode-validation-rule)
5. [  05   Wildcard Validation Performance Fix  ](#wildcard-validation-performance-fix)
6. [  06   Key Takeaways  ](#key-takeaways)

 Laravel 13.24 was released on August 4, 2026, bringing meaningful additions to the image API, Eloquent query builder, and validation layer — plus a performance fix that could save your app from multi-minute stalls on large payloads.

Dominant Color Detection
------------------------

The first-party image API now exposes a `dominantColor()` method. It downsamples the image to a single pixel and returns the result as a hex string, making it ideal for placeholder backgrounds while a full image loads.

```php
use Illuminate\Support\Facades\Image;

$color = Image::fromPath(storage_path('app/photo.jpg'))->dominantColor();
// "#8a6f4c"

```

The result is memoized per instance, and any pending transformations run before sampling — so you get the color of the image you are about to store, not the original. You can also pass `'dominant'` as the `background` argument to `contain()` or `rotate()`, filling letterbox bars or rotation corners with the image's own color automatically:

```php
Image::fromUpload($request->file('photo'))
    ->contain(1200, 800, background: 'dominant')
    ->store('photos');

```

HEIC and AVIF Input/Output
--------------------------

Previously, AVIF files were rejected on input and HEIC/HEIF were unsupported in both directions, meaning iPhone photos had to be converted before reaching the framework. Laravel 13.24 fixes this:

- AVIF, HEIC, and HEIF are now accepted as inputs.
- `toHeic()` and `optimize('heic')` are available as outputs.
- All three formats are recognized by the `image` validation rule.

```php
Image::fromPath(storage_path('app/photo.heic'))
    ->usingImagick()
    ->cover(1200, 800)
    ->toAvif()
    ->quality(80)
    ->store('photos');

```

> **Note:** HEIC processing requires an Imagick build with the HEIC codec compiled in. `image/heif` MIME types are normalized to `.heic` on storage.

`modelKeys()` on the Eloquent Query Builder
-------------------------------------------

Eloquent collections have long had `modelKeys()`, but retrieving primary keys directly from a query required hardcoding `pluck('id')`. The query builder now supports it natively:

```php
$ids = Post::query()->where('published', true)->modelKeys();
// [1, 2, 3]

```

It uses the model's qualified key name, so custom `$primaryKey` values and joined queries resolve correctly without any column hardcoding.

New `array_keys` Validation Rule
--------------------------------

The existing `Rule::array()` rejects unexpected keys but reports a generic failure message. The new `array_keys` rule focuses solely on key constraints and provides a clearer error:

```php
$request->validate([
    'options' => Rule::arrayKeys(['sort', 'direction']),
]);

```

Given `['sort' => 'name', 'colour' => 'red']`, the message reads: *"The options field must only contain the following keys: sort, direction."*

Custom messages can use `:values` (accepted keys) or `:unexpected` (the offending keys), which is especially useful in API responses:

```php
$request->validate(
    ['options' => Rule::arrayKeys(['sort', 'direction'])],
    ['options.array_keys' => 'The :attribute field may not contain :unexpected.']
);
// The options field may not contain colour.

```

Wildcard Validation Performance Fix
-----------------------------------

Expanding `foo.*.bar` rules was quadratic in the number of expanded attributes. At 8,000 array items (roughly 1.1 MB), validation could take over 85 seconds — before a single rule ran. The fix moves the merge logic into a method that takes the accumulator by reference:

| Items | Before | After | |-------|---------|--------| | 1,000 | 0.98s | 0.11s | | 4,000 | 18.59s | 0.47s | | 8,000 | 85.13s | 0.98s |

Note that `explodeWildcardRules()` no longer calls `mergeRulesForAttribute()`, so overrides of that method will no longer affect wildcard expansion.

Key Takeaways
-------------

- `dominantColor()` returns a hex string and works as a `background` value in `contain()` and `rotate()`.
- HEIC and AVIF are now fully supported for input and output; Imagick with the HEIC codec is required for HEIC.
- `modelKeys()` on the query builder eliminates the need to hardcode primary key column names.
- The `array_keys` rule gives precise, actionable validation messages for unexpected array keys.
- The wildcard validation fix reduces an 85-second stall to under 1 second for 8,000-item arrays.
- `Arr::forget()` now correctly removes the intended keys when processing mixed dotted and top-level keys.

---

*Source: [Laravel News — Laravel 13.24.0](https://laravel-news.com/laravel-13-24-0)*

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fimage-dominant-color-and-heic-support-in-laravel-1324&text=Image+Dominant+Color+and+HEIC+Support+in+Laravel+13.24) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fimage-dominant-color-and-heic-support-in-laravel-1324) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  Does HEIC image support in Laravel 13.24 work with any server setup?        No. HEIC processing requires that your server's Imagick extension is compiled with the HEIC codec. If that codec is absent, HEIC input and output will not work even after upgrading to Laravel 13.24. 

      Q02  What is the difference between the new array\_keys rule and the existing Rule::array() in Laravel?        Rule::array() validates that a field is an array and optionally restricts its keys, but reports a generic failure message. The new array_keys rule focuses only on key constraints and provides a specific message naming the unexpected keys, including an :unexpected placeholder for custom messages. 

      Q03  Will the wildcard validation fix in Laravel 13.24 affect applications that override mergeRulesForAttribute()?        Yes. The fix moves wildcard expansion logic so that explodeWildcardRules() no longer routes through mergeRulesForAttribute(). If your application overrides that method, the override will no longer affect wildcard rule expansion. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://msaied.com/articles) 

 [ ![Official Laravel Zed Extension: LSP Support for PHP and Blade Files](https://cdn.msaied.com/511/9a507c942d0051cc70a4c6769b27f734.png) Laravel Zed LSP 

### Official Laravel Zed Extension: LSP Support for PHP and Blade Files

The Laravel team has released an official Zed extension (v0.1.0) that wires Laravel LSP into the editor, bring...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 4 Aug 2026     3 min read  

  Read    

 ](https://msaied.com/articles/official-laravel-zed-extension-lsp-support-for-php-and-blade-files) [ ![Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD in Laravel 13](https://cdn.msaied.com/512/4b4bedfc34f26b38c69fed3a3b5813e9.png) Laravel SEO Open Graph 

### Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD in Laravel 13

Laravel Head is a new first-party package that gives you a fluent API for titles, meta descriptions, Open Grap...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 4 Aug 2026     4 min read  

  Read    

 ](https://msaied.com/articles/laravel-head-manage-meta-tags-open-graph-and-json-ld-in-laravel-13) [ ![PostgreSQL CTEs, Window Functions, and Lateral Joins in Laravel](https://cdn.msaied.com/506/7d5fcddaf6c26c87a749a20b8bdffbfa.png) laravel postgresql sql 

### PostgreSQL CTEs, Window Functions, and Lateral Joins in Laravel

Go beyond basic Eloquent queries. Learn how to leverage PostgreSQL CTEs, window functions, and LATERAL joins d...

  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MJ.jpg)  Mohamed Said 

 4 Aug 2026     1 min read  

  Read    

 ](https://msaied.com/articles/postgresql-ctes-window-functions-and-lateral-joins-in-laravel-4) 

   [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

Explore

- [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
