PHPackages                             cviebrock/image-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. cviebrock/image-validator

Abandoned → [illuminate/validation](/?search=illuminate%2Fvalidation)Library[Image &amp; Media](/categories/media)

cviebrock/image-validator
=========================

Custom Laravel Validator for image dimensions - abandoned since these are now built in to Laravel 5.2 and later

2.2.3(8y ago)223457.5k—0%516MITPHPPHP &gt;=5.6.4

Since Dec 16Pushed 8y ago8 watchersCompare

[ Source](https://github.com/cviebrock/image-validator)[ Packagist](https://packagist.org/packages/cviebrock/image-validator)[ Docs](https://github.com/cviebrock/image-validator)[ RSS](/packages/cviebrock-image-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (23)Used By (6)

Image-Validator
===============

[](#image-validator)

Extra validation rules for dealing with images in Laravel 5.

> *NOTE*: As of Laravel version 5.2, there are now [built-in validation rules for image dimensions and aspect ratios](https://laravel.com/docs/validation#rule-dimensions). This package is not required and will no longer be maintained.

[![Build Status](https://camo.githubusercontent.com/ed0a5acb280d620fcf660855d20b246d0ddae71991ad4383435a4f40ed39e017/68747470733a2f2f7472617669732d63692e6f72672f6376696562726f636b2f696d6167652d76616c696461746f722e7376673f6272616e63683d6d617374657226666f726d61743d666c6174)](https://travis-ci.org/cviebrock/image-validator)[![Total Downloads](https://camo.githubusercontent.com/f7fa1a66deee1ddc1b4ccb1db03fd31b2cb6bccf01fa2057b707f69fda66202a/68747470733a2f2f706f7365722e707567782e6f72672f6376696562726f636b2f696d6167652d76616c696461746f722f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/cviebrock/image-validator)[![Latest Stable Version](https://camo.githubusercontent.com/43460ea50a3d75666a2e63cb65498001cbc96c0d660440d344bcb34c0c562f34/68747470733a2f2f706f7365722e707567782e6f72672f6376696562726f636b2f696d6167652d76616c696461746f722f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/cviebrock/image-validator)[![Latest Unstable Version](https://camo.githubusercontent.com/fe788cd1ec0ad02500c5a24c0d9b9fb872076be7e6de48cfc2f2961f2d058923/68747470733a2f2f706f7365722e707567782e6f72672f6376696562726f636b2f696d6167652d76616c696461746f722f762f756e737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/cviebrock/image-validator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/73774f49defa8d29b615dcc8385e6d9236467470ca25bad959fe6554ef5b0308/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6376696562726f636b2f696d6167652d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f666f726d61743d666c6174)](https://scrutinizer-ci.com/g/cviebrock/image-validator)[![SensioLabsInsight](https://camo.githubusercontent.com/fd9e0997f01f8748d075bc7d37cf79097c34ba3d0650716bfb46c2304f95b1f8/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62633263396539302d326564662d343034372d396233632d6135616131356461313635622f6d696e692e706e67)](https://insight.sensiolabs.com/projects/bc2c9e90-2edf-4047-9b3c-a5aa15da165b)[![License: MIT](https://camo.githubusercontent.com/c2bffd81d308ced1cc3b0d66fb0ed453ab478a5e17c988b780f9de986a390ee2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)

- [Installation](#installation)
- [Usage](#usage)
    - [image\_size](#image_size)
    - [image\_aspect](#image_aspect)
- [Examples](#examples)
- [Bugs, Suggestions and Contributions](#bugs-suggestions-and-contributions)
- [Copyright and License](#copyright-and-license)

---

Installation
------------

[](#installation)

> **NOTE**: Depending on your version of Laravel, you should install a different version of the package:
>
> Laravel VersionPackage Version4.\*1.x5.0–5.32.1†5.42.2†5.5not supported†† Laravel 5.2 and later have [built-in validation rules for image dimensions](https://laravel.com/docs/5.5/validation#rule-dimensions).

Install the package through [Composer](http://getcomposer.org).

```
composer require "cviebrock/image-validator"
```

Add the following to your `providers` array in `app/config/app.php`:

```
'providers' => [
    ...
    \Cviebrock\ImageValidator\ImageValidatorServiceProvider::class,
],
```

Usage
-----

[](#usage)

Use it like any `Validator` rule. The package offers two rules for image validation:

### image\_size

[](#image_size)

```
$rules = [
    'my_image_field' => 'image_size:[,]',
];
```

The values for *width* and \_height can be integers, or integers with a modifier prefix:

- `300` or `=300` means the dimension must be exactly 300 pixels.
- `=300` means the dimension must be greater than or equal to 300 pixels
- `200-300` means the dimension must be between 200 and 300 pixels (inclusive)
- `*` means the dimension can be any value

If you only pass one value, it's assumed to apply to both dimensions (i.e. a square image with the given dimensions).

### image\_aspect

[](#image_aspect)

```
$rules = [
    'my_image_field' => 'image_aspect:',
];
```

The value for *ratio* represents *width ÷ height* and be either a decimal or two values (width, height; both integers):

- `0.75`
- `3,4`

The value (or first value, if providing height and width) can also be prefixed with a tilde `~` character, in which case the orientation does not matter:

- `~3,4` means the image can have an aspect ratio of either 3:4 or 4:3.

Note that you may run into issues with floating point rounding.

Examples
--------

[](#examples)

```
// logo must be 300px wide by 400px tall
$rules = [
    'logo' => 'required|image|image_size:300,400',
];

// logo must be less than or equal to 300x300px.
$rules = [
    'logo' => 'required|image|image_size:=100,200-300',
];

// logo must be square
$rules = [
    'logo' => 'required|image|image_aspect:1',
];

// logo must be ready for the big screen TV :)
$rules = [
    'logo' => 'required|image|image_aspect:16,9',
];
```

Bugs, Suggestions and Contributions
-----------------------------------

[](#bugs-suggestions-and-contributions)

Thanks to [everyone](https://github.com/cviebrock/image-validator/graphs/contributors)who has contributed to this project!

Please use [Github](https://github.com/cviebrock/image-validator) for reporting bugs, and making comments or suggestions.

See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes.

Copyright and License
---------------------

[](#copyright-and-license)

[image-validator](https://github.com/cviebrock/image-validator)was written by [Colin Viebrock](http://viebrock.ca) and is released under the [MIT License](LICENSE.md).

Copyright 2013 Colin Viebrock

Thanks
------

[](#thanks)

Lots of thanks to  for the structure of creating a package to add validator rules to Laravel, and setting up useful unit tests.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 82% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Recently: every ~52 days

Total

22

Last Release

3177d ago

Major Versions

0.1.1 → 1.0.02014-02-04

1.0.4 → 2.0.0-alpha2015-02-17

1.0.5 → 2.2.22017-04-04

PHP version history (3 changes)0.1.0PHP &gt;=5.3.0

1.0.0PHP &gt;=5.4.0

2.2.0PHP &gt;=5.6.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/a3b6c8249f9ade65deeb3667fdf717ca934828c0c5fd2341dfdb62ab01414791?d=identicon)[cviebrock](/maintainers/cviebrock)

---

Top Contributors

[![cviebrock](https://avatars.githubusercontent.com/u/166810?v=4)](https://github.com/cviebrock "cviebrock (91 commits)")[![saeedsajadi](https://avatars.githubusercontent.com/u/3465334?v=4)](https://github.com/saeedsajadi "saeedsajadi (3 commits)")[![Ardakilic](https://avatars.githubusercontent.com/u/2063957?v=4)](https://github.com/Ardakilic "Ardakilic (3 commits)")[![scvaer](https://avatars.githubusercontent.com/u/12242082?v=4)](https://github.com/scvaer "scvaer (2 commits)")[![utkuyildirim](https://avatars.githubusercontent.com/u/1185506?v=4)](https://github.com/utkuyildirim "utkuyildirim (2 commits)")[![keyduq](https://avatars.githubusercontent.com/u/4933682?v=4)](https://github.com/keyduq "keyduq (1 commits)")[![mgoebelm](https://avatars.githubusercontent.com/u/1482604?v=4)](https://github.com/mgoebelm "mgoebelm (1 commits)")[![nWidart](https://avatars.githubusercontent.com/u/882397?v=4)](https://github.com/nWidart "nWidart (1 commits)")[![php-cpm](https://avatars.githubusercontent.com/u/14024606?v=4)](https://github.com/php-cpm "php-cpm (1 commits)")[![Shonetow](https://avatars.githubusercontent.com/u/4283547?v=4)](https://github.com/Shonetow "Shonetow (1 commits)")[![willwashburn](https://avatars.githubusercontent.com/u/957608?v=4)](https://github.com/willwashburn "willwashburn (1 commits)")[![awgv](https://avatars.githubusercontent.com/u/6409354?v=4)](https://github.com/awgv "awgv (1 commits)")[![CaraWang](https://avatars.githubusercontent.com/u/4214689?v=4)](https://github.com/CaraWang "CaraWang (1 commits)")[![Djuki](https://avatars.githubusercontent.com/u/416411?v=4)](https://github.com/Djuki "Djuki (1 commits)")[![GaraiViktor](https://avatars.githubusercontent.com/u/12095422?v=4)](https://github.com/GaraiViktor "GaraiViktor (1 commits)")

---

Tags

laravelvalidatorimagedeprecated

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/cviebrock-image-validator/health.svg)

```
[![Health](https://phpackages.com/badges/cviebrock-image-validator/health.svg)](https://phpackages.com/packages/cviebrock-image-validator)
```

###  Alternatives

[cmgmyr/messenger

Simple user messaging tool for Laravel

2.6k2.4M6](/packages/cmgmyr-messenger)[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
