Laravel 13.24: Dominant Color, HEIC &amp; More | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Image Dominant Color and HEIC Support in Laravel 13.24

   [Laravel](https://www.msaied.com/public/articles?category=laravel) 

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

 Laravel 13.24 adds dominant color detection, HEIC/AVIF image support, a modelKeys() query builder method, a new array\_keys validation rule, and a critical fix for quadratic wildcard validation slowdowns.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 4 Aug 2026 · Updated 6 Aug 2026 · 4 min read

ShareCopy linkCopied

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

  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)

 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)*

- [Laravel 13.24](https://www.msaied.com/public/articles?search=Laravel%2013.24)
- [Image API](https://www.msaied.com/public/articles?search=Image%20API)
- [HEIC](https://www.msaied.com/public/articles?search=HEIC)
- [Validation](https://www.msaied.com/public/articles?search=Validation)
- [Eloquent](https://www.msaied.com/public/articles?search=Eloquent)
- [Performance](https://www.msaied.com/public/articles?search=Performance)

 Frequently asked questions 
---------------------------

  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.

   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.

   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.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

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

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleOfficial Laravel Zed Extension: LSP Support for PHP and Blade Files](https://www.msaied.com/public/articles/official-laravel-zed-extension-lsp-support-for-php-and-blade-files) [Next articleLaravel Boost Project Rules: Teach AI Agents Your Team's Conventions](https://www.msaied.com/public/articles/laravel-boost-project-rules-teach-ai-agents-your-teams-conventions)  

   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)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
