{"id":16444440,"url":"https://github.com/cviebrock/image-validator","last_synced_at":"2025-10-07T17:24:09.430Z","repository":{"id":12543419,"uuid":"15213505","full_name":"cviebrock/image-validator","owner":"cviebrock","description":"Laravel validator rules for image dimensions - Deprecated; see:","archived":false,"fork":false,"pushed_at":"2017-10-05T14:00:27.000Z","size":117,"stargazers_count":223,"open_issues_count":0,"forks_count":52,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-24T02:07:10.048Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://laravel.com/docs/validation#rule-dimensions","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cviebrock.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-16T00:15:40.000Z","updated_at":"2025-05-15T06:56:26.000Z","dependencies_parsed_at":"2022-09-23T07:52:03.059Z","dependency_job_id":null,"html_url":"https://github.com/cviebrock/image-validator","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/cviebrock/image-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cviebrock%2Fimage-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cviebrock%2Fimage-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cviebrock%2Fimage-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cviebrock%2Fimage-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cviebrock","download_url":"https://codeload.github.com/cviebrock/image-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cviebrock%2Fimage-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278812049,"owners_count":26050229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T09:24:26.397Z","updated_at":"2025-10-07T17:24:09.392Z","avatar_url":"https://github.com/cviebrock.png","language":"PHP","funding_links":[],"categories":["过滤和验证( Filtering ang Validation )"],"sub_categories":[],"readme":"# Image-Validator\n\nExtra validation rules for dealing with images in Laravel 5.\n\n\u003e *NOTE*: As of Laravel version 5.2, there are now\n[built-in validation rules for image dimensions and aspect ratios](https://laravel.com/docs/validation#rule-dimensions).\n\u003e This package is not required and will no longer be maintained.\n\n[![Build Status](https://travis-ci.org/cviebrock/image-validator.svg?branch=master\u0026format=flat)](https://travis-ci.org/cviebrock/image-validator)\n[![Total Downloads](https://poser.pugx.org/cviebrock/image-validator/downloads?format=flat)](https://packagist.org/packages/cviebrock/image-validator)\n[![Latest Stable Version](https://poser.pugx.org/cviebrock/image-validator/v/stable?format=flat)](https://packagist.org/packages/cviebrock/image-validator)\n[![Latest Unstable Version](https://poser.pugx.org/cviebrock/image-validator/v/unstable?format=flat)](https://packagist.org/packages/cviebrock/image-validator)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/cviebrock/image-validator/badges/quality-score.png?format=flat)](https://scrutinizer-ci.com/g/cviebrock/image-validator)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/bc2c9e90-2edf-4047-9b3c-a5aa15da165b/mini.png)](https://insight.sensiolabs.com/projects/bc2c9e90-2edf-4047-9b3c-a5aa15da165b)\n[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n\n* [Installation](#installation)\n* [Usage](#usage)\n  * [image_size](#image_size)\n  * [image_aspect](#image_aspect)\n* [Examples](#examples)\n* [Bugs, Suggestions and Contributions](#bugs-suggestions-and-contributions)\n* [Copyright and License](#copyright-and-license)\n\n---\n\n## Installation\n\n\u003e **NOTE**: Depending on your version of Laravel, you should install a different\n\u003e version of the package:\n\u003e \n\u003e | Laravel Version | Package Version |\n\u003e |:---------------:|:---------------:|\n\u003e |       4.*       |       1.x       |\n\u003e |     5.0–5.3     |       2.1†      |\n\u003e |       5.4       |       2.2†      |\n\u003e |       5.5       |  not supported† |\n\u003e\n\u003e † Laravel 5.2 and later have [built-in validation rules for image dimensions](https://laravel.com/docs/5.5/validation#rule-dimensions).\n\nInstall the package through [Composer](http://getcomposer.org).\n\n```shell\ncomposer require \"cviebrock/image-validator\"\n```\n\nAdd the following to your `providers` array in `app/config/app.php`:\n\n```php\n'providers' =\u003e [\n    ...\n    \\Cviebrock\\ImageValidator\\ImageValidatorServiceProvider::class,\n],\n```\n\n\n\n## Usage\n\nUse it like any `Validator` rule.  The package offers two rules for image validation:\n\n### image_size\n\n```php\n$rules = [\n    'my_image_field' =\u003e 'image_size:\u003cwidth\u003e[,\u003cheight\u003e]',\n];\n```\n\nThe values for _width_ and _height can be integers, or integers with a modifier prefix:\n\n- `300` or `=300` means the dimension must be exactly 300 pixels.\n- `\u003c300` means the dimension must be less than 300 pixels\n- `\u003c=300` means the dimension must be less than or equal to 300 pixels\n- `\u003e300` means the dimension must be greater than 300 pixels\n- `\u003e=300` means the dimension must be greater than or equal to 300 pixels\n- `200-300` means the dimension must be between 200 and 300 pixels (inclusive)\n- `*` means the dimension can be any value\n\nIf you only pass one value, it's assumed to apply to both dimensions \n(i.e. a square image with the given dimensions).\n\n### image_aspect\n\n```php\n$rules = [\n    'my_image_field' =\u003e 'image_aspect:\u003cratio\u003e',\n];\n```\n\nThe value for _ratio_ represents _width ÷ height_ and be either a decimal or \ntwo values (width, height; both integers):\n\n- `0.75`\n- `3,4`\n\nThe value (or first value, if providing height and width) can also be prefixed \nwith a tilde `~` character, in which case the orientation does not matter:\n\n- `~3,4` means the image can have an aspect ratio of either 3:4 or 4:3.\n\nNote that you may run into issues with floating point rounding.\n\n\n## Examples\n\n```php\n// logo must be 300px wide by 400px tall\n$rules = [\n    'logo' =\u003e 'required|image|image_size:300,400',\n];\n\n// logo must be less than or equal to 300x300px.\n$rules = [\n    'logo' =\u003e 'required|image|image_size:\u003c=300',\n];\n\n// logo must be 300px wide but can be any height\n$rules = [\n    'logo' =\u003e 'required|image|image_size:300,*',\n];\n\n// logo must be at least 100px tall and 200-300 pixels wide (inclusive)\n$rules = [\n    'logo' =\u003e 'required|image|image_size:\u003e=100,200-300',\n];\n\n// logo must be square\n$rules = [\n    'logo' =\u003e 'required|image|image_aspect:1',\n];\n\n// logo must be ready for the big screen TV :)\n$rules = [\n    'logo' =\u003e 'required|image|image_aspect:16,9',\n];\n```\n\n\n\n## Bugs, Suggestions and Contributions\n\nThanks to [everyone](https://github.com/cviebrock/image-validator/graphs/contributors)\nwho has contributed to this project!\n\nPlease use [Github](https://github.com/cviebrock/image-validator) for reporting bugs, \nand making comments or suggestions.\n \nSee [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes.\n\n\n\n## Copyright and License\n\n[image-validator](https://github.com/cviebrock/image-validator)\nwas written by [Colin Viebrock](http://viebrock.ca) and is released under the \n[MIT License](LICENSE.md).\n\nCopyright 2013 Colin Viebrock\n\n\n\n## Thanks\n\nLots of thanks to https://bitbucket.org/hampel/validate-laravel for the \nstructure of creating a package to add validator rules to Laravel, \nand setting up useful unit tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcviebrock%2Fimage-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcviebrock%2Fimage-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcviebrock%2Fimage-validator/lists"}