[
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "This package has been abandoned since Laravel 5.2 and later now include built-in rules to validate images:\n\nhttps://laravel.com/docs/5.5/validation#rule-dimensions\n\nIssues for fixes to versions prior to Laravel 5.2 will be addressed on a case-by-case basis.\n\n**Thank you!**\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "Thank you for helping to make this package better!\n\nHowever, this package has been abandoned since Laravel 5.2 and later now include built-in rules to validate images:\n\nhttps://laravel.com/docs/5.5/validation#rule-dimensions\n\nPull requests are now longer being accepted.\n\n**Thank you!**\n"
  },
  {
    "path": ".gitignore",
    "content": "/build/\n/vendor/\ncomposer.lock\ncomposer.phar\n"
  },
  {
    "path": ".nitpick.json",
    "content": "{\n  \"ignore\": [\n    \"tests/*\"\n  ]\n}\n"
  },
  {
    "path": ".scrutinizer.yml",
    "content": "filter:\n    paths: ['src/*']\nchecks:\n    php:\n        code_rating: true\n        remove_extra_empty_lines: true\n        remove_php_closing_tag: true\n        remove_trailing_whitespace: true\n        fix_use_statements:\n            remove_unused: true\n            preserve_multiple: false\n            preserve_blanklines: true\n            order_alphabetically: true\n        fix_php_opening_tag: true\n        fix_linefeed: true\n        fix_line_ending: true\n        fix_identation_4spaces: true\n        fix_doc_comments: true\ntools:\n    external_code_coverage: false\n    php_analyzer: true\n    php_code_coverage: false\n    php_code_sniffer:\n        config:\n            standard: PSR2\n        filter:\n            paths: ['src']\n    php_loc:\n        enabled: true\n        excluded_dirs: [vendor, tests]\n    php_cpd:\n        enabled: true\n        excluded_dirs: [vendor, tests]\n"
  },
  {
    "path": ".semver",
    "content": "---\n:major: 2\n:minor: 2\n:patch: 2\n:special: ''\n:metadata: ''\n"
  },
  {
    "path": ".travis.yml",
    "content": "# Travis CI configuration\n\nlanguage: php\n\nphp:\n  - 5.6\n  - 7.0\n\nmatrix:\n  include:\n    - php: 5.6\n      env: 'COMPOSER_FLAGS=\"--prefer-stable --prefer-lowest\"'\n\nbefore_script:\n  - travis_retry composer self-update\n  - travis_retry composer install --prefer-source --no-interaction --dev $PREFER_LOWEST\n\nscript:\n  - php vendor/bin/phpunit\n\nafter_script:\n  - php vendor/bin/ocular code-coverage:upload --format=php-clover build/clover.xml\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Change Log\n\n## 2.2.2 - 04-Apr-2017\n\n- Correction to Italian (#55, thanks @neomusic)\n\n\n## 2.2.1 - 08-Feb-2017\n\n- Hungarian translation (#54, thanks @GaraiViktor)\n\n\n## 2.2.0 - 07-Feb-2017\n\n- Laravel 5.4 support\n\n\n## 2.1.5 - 30-Jan-2017\n\n- Correction to Persian (#51, thanks @smart-twists)\n- Estonian translation (#52, thanks @kaidoj)\n \n\n## 2.1.4 - 13-Dec-2016\n\n- Serbian (Latin) translation (#49, thanks @Shonetow)\n- Persian translation (#50, thanks @smart-twists)\n\n\n## 2.1.3 - 12-Aug-2016\n\n- Chinese-Simplified translation (#48, thanks @php-cpm)\n\n\n## 2.1.2 - 20-Jul-2016\n\n- Chinese-Traditional translation (#47, thanks @CaraWang)\n\n\n## 2.1.1 - 19-Jul-2016\n\n- Fix for translations not loading in closure (#45, thanks @nWidart)\n\n\n## 2.1.0 - 27-May-2016\n\n- Latvian translation (#42, thanks @scvaer)\n- Fix for aspect ratio checking on images where the result would be fractional pixels (#31)\n- Fix where aspect error message only lists one parameter when using `3,2` format for aspect (#41)\n- Fix for Lumen (#44, thanks @WrongWay)\n- Fix where translations aren't yet available (#30, thanks @superdummy)\n\n\n## 2.0.1 - 11-Apr-2016\n\n- Spanish translation (#32, thanks @keyduq).\n- French translation fixes (#39, thanks @DevJuju).\n\n\n## 2.0.0 - 07-Oct-2015\n\n- Russian translation (#29, thanks @DexinDev).\n\n\n## 2.0.0-beta - 02-Mar-2015\n\n- Laravel 5 release version.\n- German and Dutch translations (#18 and #19, thanks @gpluess).\n\n\n## 2.0.0-alpha - 11-Feb-2015\n\n- Laravel 5 alpha version.\n\n\n## 1.0.5 - 11-Feb-2015\n\n- Fixed Turkish translation (#7, thanks @mayoz).\n- Fixed Italian translation (#55, thanks @neomusic).\n- Last version that works with Laravel 4.\n\n\n## 1.0.4 - 17-Jun-2014\n\n- Added translation for French (merci @yazuu).\n\n\n## 1.0.3 - 04-Jun-2014\n\n- Added translations for Portuguese (thanks @helio-correia) and Turkish (thanks @Ardakilic).\n\n\n## 1.0.2 - 04-Feb-2014\n\n- Bug fixes.\n\n\n## 1.0.0 - 04-Feb-2014\n\n- Rename package to `cviebrock/image-validator`.\n- Require Laravel >= 4.1.21 due to validation replacement rules.\n- Use better validation extension.\n\n\n## 0.2.0 - 20-Dec-2013\n\n- Added `image_aspect` validation.\n\n\n## 0.1.1 - 16-Dec-2013\n\n- Initial release.\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\nContributions are **welcome** and will be fully **credited**.\n\nWe accept contributions via pull requests via \n[Github](https://github.com/cviebrock/image-validator).\n\n1. Fork the project.\n2. Create your bugfix/feature branch and write your (well-commented) code.\n3. Create unit tests for your code:\n\t- Run `composer install --dev` in the root directory to install required testing packages.\n\t- Add your test classes/methods to the `/tests/` directory.\n\t- Run `vendor/bin/phpunit` and make sure everything passes (new and old tests).\n3. Commit your changes (and your tests) and push to your branch.\n4. Create a new pull request against this package's `master` branch.\n\n\n## Pull Requests\n\n- **Use the [PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).**\n  The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).\n\n- **Add tests!**  Your pull request won't be accepted if it doesn't have tests.\n\n- **Document any change in behaviour.**  Make sure the `README.md` and any other relevant \n  documentation are kept up-to-date.\n\n- **Consider our release cycle.**  We try to follow [SemVer v2.0.0](http://semver.org/). \n  Randomly breaking public APIs is not an option.\n\n- **Create feature branches.**  Don't ask us to pull from your master branch.\n\n- **One pull request per feature.**  If you want to do more than one thing, send multiple pull requests.\n\n- **Send coherent history.** - Make sure each individual commit in your pull request is meaningful. \n  If you had to make multiple intermediate commits while developing, please \n  [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages)\n  before submitting.\n\n- Don't worry about updating `CHANGELOG.md` or `.semver`.  The package administrator\n  will handle updating those when new releases are created.\n  \n\n**Thank you!**\n"
  },
  {
    "path": "LICENSE.md",
    "content": "# The MIT License (MIT)\n\nCopyright (c) 2013 Colin Viebrock <colin@viebrock.ca>\n\n> Permission is hereby granted, free of charge, to any person obtaining a copy\n> of this software and associated documentation files (the \"Software\"), to deal\n> in the Software without restriction, including without limitation the rights\n> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n> copies of the Software, and to permit persons to whom the Software is\n> furnished to do so, subject to the following conditions:\n> \n> The above copyright notice and this permission notice shall be included in all\n> copies or substantial portions of the Software.\n> \n> THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n> SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Image-Validator\n\nExtra validation rules for dealing with images in Laravel 5.\n\n> *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> 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&format=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> **NOTE**: Depending on your version of Laravel, you should install a different\n> version of the package:\n> \n> | Laravel Version | Package Version |\n> |:---------------:|:---------------:|\n> |       4.*       |       1.x       |\n> |     5.0–5.3     |       2.1†      |\n> |       5.4       |       2.2†      |\n> |       5.5       |  not supported† |\n>\n> † 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' => [\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' => 'image_size:<width>[,<height>]',\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- `<300` means the dimension must be less than 300 pixels\n- `<=300` means the dimension must be less than or equal to 300 pixels\n- `>300` means the dimension must be greater than 300 pixels\n- `>=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' => 'image_aspect:<ratio>',\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' => 'required|image|image_size:300,400',\n];\n\n// logo must be less than or equal to 300x300px.\n$rules = [\n    'logo' => 'required|image|image_size:<=300',\n];\n\n// logo must be 300px wide but can be any height\n$rules = [\n    'logo' => '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' => 'required|image|image_size:>=100,200-300',\n];\n\n// logo must be square\n$rules = [\n    'logo' => 'required|image|image_aspect:1',\n];\n\n// logo must be ready for the big screen TV :)\n$rules = [\n    'logo' => '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"
  },
  {
    "path": "TODO.md",
    "content": "# TODO\n\n- [ ] add more rules?\n- [ ] make error messages publishable via `artisan vendor:publish`\n- [ ] test in an actual Laravel 5 project\n- [ ] test validator messages / translations\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"cviebrock/image-validator\",\n    \"description\": \"Custom Laravel Validator for image dimensions - abandoned since these are now built in to Laravel 5.2 and later\",\n    \"keywords\": [\n        \"laravel\",\n        \"validator\",\n        \"image\",\n        \"deprecated\"\n    ],\n    \"homepage\": \"https://github.com/cviebrock/image-validator\",\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Colin Viebrock\",\n            \"email\": \"colin@viebrock.ca\"\n        }\n    ],\n    \"require\": {\n        \"php\": \">=5.6.4\",\n        \"illuminate/config\": \"^5.4\",\n        \"illuminate/database\": \"^5.4\",\n        \"illuminate/support\": \"^5.4\"\n    },\n    \"require-dev\": {\n        \"friendsofphp/php-cs-fixer\": \"^1.11\",\n        \"mockery/mockery\": \"^0.9.4\",\n        \"orchestra/testbench\": \"^3.4\",\n        \"phpunit/phpunit\": \"~5.7\",\n        \"scrutinizer/ocular\": \"^1.3\"\n    },\n    \"autoload\": {\n        \"psr-4\": {\n            \"Cviebrock\\\\ImageValidator\\\\\": \"src/\"\n        }\n    },\n    \"autoload-dev\": {\n        \"psr-4\": {\n            \"Cviebrock\\\\ImageValidator\\\\Test\\\\\": \"tests\"\n        }\n    },\n    \"scripts\": {\n        \"test\": [\n            \"parallel-lint . --exclude vendor\",\n            \"phpunit\"\n        ]\n    },\n    \"minimum-stability\": \"dev\",\n    \"prefer-stable\": true\n}\n"
  },
  {
    "path": "lang/de/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => ':attribute muss :width breit und :height hoch sein.',\n\n    'between'            => 'zwischen :size1 und :size2 Pixel',\n    'lessthan'           => 'kleiner als :size Pixel',\n    'lessthanorequal'    => 'höchstens :size Pixel',\n    'greaterthan'        => 'größer als :size Pixel',\n    'greaterthanorequal' => 'mindestens :size Pixel',\n    'equal'              => ':size Pixel',\n    'anysize'            => 'irgendeine Größe',\n\n    'image_aspect' => 'Das Seitenverhältnis von :attribute muss :aspect sein',\n];\n"
  },
  {
    "path": "lang/en/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'The :attribute must be :width wide and :height tall.',\n\n    'between'            => 'between :size1 and :size2 pixels',\n    'lessthan'           => 'less than :size pixels',\n    'lessthanorequal'    => 'less than or equal to :size pixels',\n    'greaterthan'        => 'greater than :size pixels',\n    'greaterthanorequal' => 'greater than or equal to :size pixels',\n    'equal'              => ':size pixels',\n    'anysize'            => 'any size',\n\n    'image_aspect' => 'The :attribute aspect ratio must be :aspect.',\n];\n"
  },
  {
    "path": "lang/es/validation.php",
    "content": "<?php\n\nreturn [\n    \"image_size\" => \"El campo :attribute debe ser :width de ancho y :height de alto.\",\n\n    'between'            => 'entre :size1 y :size2 pixeles',\n    'lessthan'           => 'menor que :size pixeles',\n    'lessthanorequal'    => 'menor que o equivalente a :size pixeles',\n    'greaterthan'        => 'mayor que :size pixeles',\n    'greaterthanorequal' => 'mayor que o equivalente a :size pixeles',\n    'equal'              => ':size pixeles',\n    'anysize'            => 'cualquier tamaño',\n\n    'image_aspect' => 'El campo :attribute debe poseer un ratio de :aspect.',\n];\n"
  },
  {
    "path": "lang/et/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size'         => 'Pilt peab olema :width laiust ja :height kõrgust.',\n\n    'between'            => ':size1 ja :size2 piksli vahel',\n    'lessthan'           => 'vähem, kui :size pikslit',\n    'lessthanorequal'    => 'väiksem või võrdne :size pikslit',\n    'greaterthan'        => 'suurem, kui :size pikslit',\n    'greaterthanorequal' => 'suurem või võrdne :size pikslit',\n    'equal'              => ':size pikslit',\n    'anysize'            => 'iga suurus',\n\n    'image_aspect'       => ':attribute kuvasuhe peab olema :aspect.',\n];\n"
  },
  {
    "path": "lang/fa/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => ':attribute باید دارای طول :width و عرض  :height باشد.',\n\n    'between'            => 'بین  :size1 و :size2 پیکسل باید باشد',\n    'lessthan'           => 'کوچکتر از  :size پیکسل',\n    'lessthanorequal'    => 'کوچکتر یا برابر :size پیکسل',\n    'greaterthan'        => 'بزرگتر از :size پیکسل',\n    'greaterthanorequal' => 'بزرگتر یا برابر :size پیکسل',\n    'equal'              => ':size پیکسل',\n    'anysize'            => 'هر اندازه ای',\n\n    'image_aspect' => ':attribute تناسب طول عرص برابر :aspect باید باشد.',\n];\n"
  },
  {
    "path": "lang/fr/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'La taille de :attribute doit être :width de large et :height de haut',\n\n    'between'            => 'entre :size1 et :size2 pixels',\n    'lessthan'           => 'plus petite que :size pixels',\n    'lessthanorequal'    => 'plus petite ou égale à :size pixels',\n    'greaterthan'        => 'plus grande que :size pixels',\n    'greaterthanorequal' => 'plus grande ou égale à :size pixels',\n    'equal'              => 'de :size pixels',\n    'anysize'            => \"de n'importe quelle taille\",\n\n    'image_aspect' => 'Le ratio de :attribute doit être de :aspect',\n];\n"
  },
  {
    "path": "lang/hu/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'A(z) :attribute :width szélesnek és :height magasnak kell lennie.',\n\n    'between'            => ':size1 és :size2 pixel között',\n    'lessthan'           => 'kevesebb mint :size pixel',\n    'lessthanorequal'    => 'kevesebb vagy pont :size pixel',\n    'greaterthan'        => 'nagyobb mint :size pixel',\n    'greaterthanorequal' => 'nagyobb vagy pont :size pixel',\n    'equal'              => ':size pixel',\n    'anysize'            => 'bármilyen méret',\n\n    'image_aspect' => 'Az) :attribute képarányának :aspect kell lennie.',\n];\n"
  },
  {
    "path": "lang/it/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'Il campo :attribute dev\\'essere :width in larghezza e :height in altezza.',\n\n    'between'            => 'tra i :size1 e :size2 pixels',\n    'lessthan'           => 'minore di :size pixels',\n    'lessthanorequal'    => 'minore o uguale a :size pixels',\n    'greaterthan'        => 'maggiore di :size pixels',\n    'greaterthanorequal' => 'maggiore o uguale a :size pixels',\n    'equal'              => 'di :size pixels',\n    'anysize'            => 'qualunque dimensione',\n\n    'image_aspect' => 'Il campo :attribute deve avere un ratio uguale a :aspect.',\n];\n"
  },
  {
    "path": "lang/lv/validation.php",
    "content": "﻿<?php\n\nreturn [\n    'image_size' => ':attribute jābūt :width platam un :height augstam.',\n\n    'between'            => 'starp :size1 un :size2 pikseļiem(i)',\n    'lessthan'           => 'mazākam par :size pikseļiem(i)',\n    'lessthanorequal'    => 'mazākam vai vienādam par :size pikseļiem(i)',\n    'greaterthan'        => 'lielākam par :size pikseļiem(i)',\n    'greaterthanorequal' => 'lielākam vai vienādam par :size pikseļiem(i)',\n    'equal'              => ':size pikseļus(i)',\n    'anysize'            => 'jebkura izmēra',\n\n    'image_aspect' => ':attribute malu attiecībai jābūt :aspect.',\n];\n"
  },
  {
    "path": "lang/nl/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'Het :attribute moet :width breed en :height hoog zijn.',\n\n    'between'            => 'tussen :size1 en :size2 pixels',\n    'lessthan'           => 'kleiner dan :size pixels',\n    'lessthanorequal'    => 'maximaal :size pixels',\n    'greaterthan'        => 'groter dan :size pixels',\n    'greaterthanorequal' => 'minimaal :size pixels',\n    'equal'              => ':size pixels',\n    'anysize'            => 'elke grootte',\n\n    'image_aspect' => 'De :attribute aspect ratio moet :aspect zijn.',\n];\n"
  },
  {
    "path": "lang/pt/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'O campo :attribute tem que ser :width de largura e :height de altura.',\n\n    'between'            => 'entre :size1 e :size2 pixels',\n    'lessthan'           => 'menor que :size pixels',\n    'lessthanorequal'    => 'menor ou igual a :size pixels',\n    'greaterthan'        => 'maior que :size pixels',\n    'greaterthanorequal' => 'maior ou igual a :size pixels',\n    'equal'              => 'de :size pixels',\n    'anysize'            => 'qualquer tamanho',\n\n    'image_aspect' => 'A proporção do campo :attribute tem que ser de :aspect.',\n];\n"
  },
  {
    "path": "lang/pt-BR/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => 'O campo :attribute tem que ser :width de largura e :height de altura.',\n\n    'between'            => 'entre :size1 e :size2 pixels',\n    'lessthan'           => 'menor que :size pixels',\n    'lessthanorequal'    => 'menor ou igual a :size pixels',\n    'greaterthan'        => 'maior que :size pixels',\n    'greaterthanorequal' => 'maior ou igual a :size pixels',\n    'equal'              => 'de :size pixels',\n    'anysize'            => 'qualquer tamanho',\n\n    'image_aspect' => 'A proporção do campo :attribute tem que ser de :aspect.',\n];\n"
  },
  {
    "path": "lang/ru/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size'         => 'Изображение :attribute должно быть :width по ширине и :height по высоте.',\n    'between'            => 'между :size1 и :size2  пикселей(я)',\n    'lessthan'           => 'меньше, чем :size  пикселей(я)',\n    'lessthanorequal'    => 'меньше или равно :size  пикселей(я)',\n    'greaterthan'        => 'больше, чем :size  пикселей(я)',\n    'greaterthanorequal' => 'больше или равно :size пикселей(я)',\n    'equal'              => ':size пикселей(я)',\n    'anysize'            => 'любого размера',\n\n    'image_aspect' => ':attribute сжатие должно быть :aspect.',\n];\n"
  },
  {
    "path": "lang/sr/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size'         => ':attribute mora biti :width u širini i :height u visini.',\n    'between'            => 'između :size1 i :size2 px',\n    'lessthan'           => 'manja od :size px',\n    'lessthanorequal'    => 'manja ili jednaka :size px',\n    'greaterthan'        => 'veća od :size px',\n    'greaterthanorequal' => 'veća ili jednaka :size px',\n    'equal'              => ':size px',\n    'anysize'            => 'bilo kojih dimenzija',\n    'image_aspect'       => ':attribute mora da bude u proporciji :aspect.',\n];\n"
  },
  {
    "path": "lang/tr/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => ':attribute :width genişliği ve :height yüksekliği olmalıdır.',\n\n    'between'            => ':size1 ve :size2 piksel aralığında',\n    'lessthan'           => ':size pikselden az',\n    'lessthanorequal'    => ':size piksele eşit veya az',\n    'greaterthan'        => ':size pikselden fazla',\n    'greaterthanorequal' => ':size piksele eşit veya fazla',\n    'equal'              => ':size piksel',\n    'anysize'            => 'herhangi bir',\n\n    'image_aspect' => ':attribute en/boy oranı :aspect olmalıdır.',\n];\n"
  },
  {
    "path": "lang/zh-CN/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => ':attribute 的宽度为 :width, 高度为 :height',\n\n    'between'            => '必须在 :size1 和 :size2 像素之间',\n    'lessthan'           => '必须小于 :size 像素',\n    'lessthanorequal'    => '必须小于或等于 :size 像素',\n    'greaterthan'        => '必须大于 :size 像素',\n    'greaterthanorequal' => '必须大于或等于 :size 像素',\n    'equal'              => '必须等于 :size 像素',\n    'anysize'            => '可以为任意大小',\n\n    'image_aspect' => ':attribute 长宽比必须为 :aspect',\n];\n"
  },
  {
    "path": "lang/zh-tw/validation.php",
    "content": "<?php\n\nreturn [\n    'image_size' => ':attribute 欄位的寬度 :width, 而高度 :height',\n\n    'between'            => '必須介於 :size1 與 :size2 像素之間',\n    'lessthan'           => '必須小於 :size 像素',\n    'lessthanorequal'    => '必須小於或等於 :size 像素',\n    'greaterthan'        => '必須大於 :size 像素',\n    'greaterthanorequal' => '必須大於或等於 :size 像素',\n    'equal'              => '必須等於 :size 像素',\n    'anysize'            => '可以是任意大小',\n\n    'image_aspect' => ':attribute 欄位的長寬比必須是 :aspect',\n];\n"
  },
  {
    "path": "phpunit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit backupGlobals=\"false\"\n    backupStaticAttributes=\"false\"\n    bootstrap=\"vendor/autoload.php\"\n    colors=\"true\"\n    convertErrorsToExceptions=\"true\"\n    convertNoticesToExceptions=\"true\"\n    convertWarningsToExceptions=\"true\"\n    processIsolation=\"false\"\n    stopOnFailure=\"false\"\n    syntaxCheck=\"false\"\n>\n    <testsuites>\n        <testsuite name=\"Image Validator Test Suite\">\n            <directory suffix=\".php\">./tests/</directory>\n        </testsuite>\n    </testsuites>\n    <filter>\n        <whitelist>\n            <directory suffix=\".php\">src/</directory>\n        </whitelist>\n    </filter>\n    <logging>\n        <log type=\"tap\" target=\"build/report.tap\"/>\n        <log type=\"junit\" target=\"build/report.junit.xml\"/>\n        <log type=\"coverage-html\" target=\"build/coverage\" charset=\"UTF-8\" yui=\"true\" highlight=\"true\"/>\n        <log type=\"coverage-text\" target=\"build/coverage.txt\"/>\n        <log type=\"coverage-clover\" target=\"build/clover.xml\"/>\n    </logging>\n</phpunit>\n"
  },
  {
    "path": "src/ImageValidator.php",
    "content": "<?php namespace Cviebrock\\ImageValidator;\n\nuse Illuminate\\Contracts\\Translation\\Translator;\nuse Illuminate\\Validation\\Validator;\nuse RuntimeException;\nuse Symfony\\Component\\HttpFoundation\\File\\UploadedFile;\n\n\nclass ImageValidator extends Validator\n{\n\n    /**\n     * Creates a new instance of ImageValidator\n     *\n     * @param \\Illuminate\\Contracts\\Translation\\Translator $translator\n     * @param array $data\n     * @param array $rules\n     * @param array $messages\n     * @param array $customAttributes\n     */\n    public function __construct(\n        Translator $translator,\n        array $data,\n        array $rules,\n        array $messages = [],\n        array $customAttributes = []\n    ) {\n        parent::__construct($translator, $data, $rules, $messages, $customAttributes);\n    }\n\n    /**\n     * Usage: image_size:width[,height]\n     *\n     * @param  $attribute  string\n     * @param  $value      string|array\n     * @param  $parameters array\n     * @return boolean\n     */\n    public function validateImageSize($attribute, $value, $parameters)\n    {\n        $image = $this->getImagePath($value);\n\n        // Get the image dimension info, or fail.\n\n        $image_size = @getimagesize($image);\n        if ($image_size === false) {\n            return false;\n        }\n\n        // If only one dimension rule is passed, assume it applies to both height and width.\n\n        if (!isset($parameters[1])) {\n            $parameters[1] = $parameters[0];\n        }\n\n        // Parse the parameters.  Options are:\n        //\n        // \t\"300\" or \"=300\"   - dimension must be exactly 300 pixels\n        // \t\"<300\"            - dimension must be less than 300 pixels\n        // \t\"<=300\"           - dimension must be less than or equal to 300 pixels\n        // \t\">300\"            - dimension must be greater than 300 pixels\n        // \t\">=300\"           - dimension must be greater than or equal to 300 pixels\n\n        $width_check = $this->checkDimension($parameters[0], $image_size[0]);\n        $height_check = $this->checkDimension($parameters[1], $image_size[1]);\n\n        return $width_check['pass'] && $height_check['pass'];\n    }\n\n    /**\n     * Build the error message for validation failures.\n     *\n     * @param  string $message\n     * @param  string $attribute\n     * @param  string $rule\n     * @param  array $parameters\n     * @return string\n     */\n    public function replaceImageSize($message, $attribute, $rule, $parameters)\n    {\n        $width = $height = $this->checkDimension($parameters[0]);\n        if (isset($parameters[1])) {\n            $height = $this->checkDimension($parameters[1]);\n        }\n\n        return str_replace(\n            [':width', ':height'],\n            [$width['message'], $height['message']],\n            $message\n        );\n    }\n\n    /**\n     * Usage: image_aspect:ratio\n     *\n     * @param  $attribute  string\n     * @param  $value      string|array\n     * @param  $parameters array\n     * @return boolean\n     * @throws \\RuntimeException\n     */\n    public function validateImageAspect($attribute, $value, $parameters)\n    {\n        $image = $this->getImagePath($value);\n\n        // Get the image dimension info, or fail.\n\n        $image_size = @getimagesize($image);\n        if ($image_size === false) {\n            return false;\n        }\n\n        $image_width = $image_size[0];\n        $image_height = $image_size[1];\n\n        // Parse the parameter(s).  Options are:\n        //\n        // \t\"0.75\"   - one param: a decimal ratio (width/height)\n        // \t\"3,4\"    - two params: width, height\n        //\n        // If the first value is prefixed with \"~\", the orientation doesn't matter, i.e.:\n        //\n        // \t\"~3,4\"   - would accept either \"3:4\" or \"4:3\" images\n\n        $both_orientations = false;\n\n        if (substr($parameters[0], 0, 1) === '~') {\n            $parameters[0] = substr($parameters[0], 1);\n            $both_orientations = true;\n        }\n\n        if (count($parameters) === 1) {\n            $aspect_width = $parameters[0];\n            $aspect_height = 1;\n        } else {\n            $aspect_width = (int) $parameters[0];\n            $aspect_height = (int) $parameters[1];\n        }\n\n        if ($aspect_width === 0 || $aspect_height === 0) {\n            throw new RuntimeException('Aspect is zero or infinite: ' . $parameters[0]);\n        }\n\n        $check = ($image_width * $aspect_height) / $aspect_width;\n\n        if ((int) round($check) === $image_height) {\n            return true;\n        }\n\n        if ($both_orientations) {\n            $check = ($image_width * $aspect_width) / $aspect_height;\n            if ((int) round($check) === $image_height) {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n    /**\n     * Build the error message for validation failures.\n     *\n     * @param  string $message\n     * @param  string $attribute\n     * @param  string $rule\n     * @param  array $parameters\n     * @return string\n     */\n    public function replaceImageAspect($message, $attribute, $rule, $parameters)\n    {\n        return str_replace(':aspect', implode(':', $parameters), $message);\n    }\n\n    /**\n     * Parse the dimension rule and check if the dimension passes the rule.\n     *\n     * @param  string $rule\n     * @param  integer $dimension\n     * @return array\n     * @throws \\RuntimeException\n     */\n    protected function checkDimension($rule, $dimension = 0)\n    {\n\n        $dimension = (int) $dimension;\n\n        if ($rule === '*') {\n            $message = $this->translator->trans('image-validator::validation.anysize');\n            $pass = true;\n        } else if (preg_match('/^(\\d+)\\-(\\d+)$/', $rule, $matches)) {\n            $size1 = (int) $matches[1];\n            $size2 = (int) $matches[2];\n            $message = $this->translator->trans('image-validator::validation.between', compact('size1', 'size2'));\n            $pass = ($dimension >= $size1) && ($dimension <= $size2);\n        } else if (preg_match('/^([<=>]*)(\\d+)$/', $rule, $matches)) {\n\n            $size = (int) $matches[2];\n\n            switch ($matches[1]) {\n                case '>':\n                    $message = $this->translator->trans('image-validator::validation.greaterthan', compact('size'));\n                    $pass = $dimension > $size;\n                    break;\n                case '>=':\n                    $message = $this->translator->trans('image-validator::validation.greaterthanorequal',\n                        compact('size'));\n                    $pass = $dimension >= $size;\n                    break;\n                case '<':\n                    $message = $this->translator->trans('image-validator::validation.lessthan', compact('size'));\n                    $pass = $dimension < $size;\n                    break;\n                case '<=':\n                    $message = $this->translator->trans('image-validator::validation.lessthanorequal', compact('size'));\n                    $pass = $dimension <= $size;\n                    break;\n                case '=':\n                case '':\n                    $message = $this->translator->trans('image-validator::validation.equal', compact('size'));\n                    $pass = $dimension == $size;\n                    break;\n                default:\n                    throw new RuntimeException('Unknown image size validation rule: ' . $rule);\n            }\n        } else {\n            throw new RuntimeException('Unknown image size validation rule: ' . $rule);\n        }\n\n        return compact('message', 'pass');\n    }\n\n    /**\n     * @param mixed $value\n     * @return string\n     */\n    protected function getImagePath($value)\n    {\n        // if were passed an instance of UploadedFile, return the path\n        if ($value instanceof UploadedFile) {\n            return $value->getPathname();\n        }\n\n        // if we're passed a PHP file upload array, return the \"tmp_name\"\n        if (is_array($value) && array_get($value, 'tmp_name') !== null) {\n            return $value['tmp_name'];\n        }\n\n        // fallback: we were likely passed a path already\n        return $value;\n    }\n}\n"
  },
  {
    "path": "src/ImageValidatorServiceProvider.php",
    "content": "<?php namespace Cviebrock\\ImageValidator;\n\nuse Illuminate\\Support\\ServiceProvider;\n\n\nclass ImageValidatorServiceProvider extends ServiceProvider\n{\n\n    /**\n     * Indicates if loading of the provider is deferred.\n     *\n     * @var bool\n     */\n    protected $defer = false;\n\n    /**\n     * @var array\n     */\n    protected $rules = [\n        'image_size',\n        'image_aspect',\n    ];\n\n    /**\n     * Bootstrap the application events.\n     *\n     * @return void\n     */\n    public function boot()\n    {\n        $this->loadTranslationsFrom(__DIR__ . '/../lang', 'image-validator');\n\n        $messages = trans('image-validator::validation');\n\n        $this->app->bind(ImageValidator::class, function($app) use ($messages) {\n            $validator = new ImageValidator($app['translator'], [], [], $messages);\n\n            if (isset($app['validation.presence'])) {\n                $validator->setPresenceVerifier($app['validation.presence']);\n            }\n\n            return $validator;\n        });\n\n        $this->addNewRules();\n    }\n\n    /**\n     * Get the list of new rules being added to the validator.\n     *\n     * @return array\n     */\n    public function getRules()\n    {\n        return $this->rules;\n    }\n\n    /**\n     * Add new rules to the validator.\n     */\n    protected function addNewRules()\n    {\n        foreach ($this->getRules() as $rule) {\n            $this->extendValidator($rule);\n        }\n    }\n\n    /**\n     * Extend the validator with new rules.\n     *\n     * @param  string $rule\n     * @return void\n     */\n    protected function extendValidator($rule)\n    {\n        $method = studly_case($rule);\n        $translation = $this->app['translator']->trans('image-validator::validation.' . $rule);\n        $this->app['validator']->extend($rule, 'Cviebrock\\ImageValidator\\ImageValidator@validate' . $method,\n            $translation);\n        $this->app['validator']->replacer($rule, 'Cviebrock\\ImageValidator\\ImageValidator@replace' . $method);\n    }\n}\n"
  },
  {
    "path": "tests/.gitkeep",
    "content": ""
  },
  {
    "path": "tests/ValidateServiceProviderTest.php",
    "content": "<?php namespace Cviebrock\\ImageValidator\\Test;\n\nuse Cviebrock\\ImageValidator\\ImageValidatorServiceProvider;\nuse Orchestra\\Testbench\\TestCase;\n\n\nclass ValidateServiceProviderTest extends TestCase\n{\n\n    protected function getPackageProviders($app)\n    {\n        return [\n            ImageValidatorServiceProvider::class,\n        ];\n    }\n\n    /**\n     * Bootstraps Laravel application. Tests service providers work on a basic level.\n     *\n     * @return void\n     */\n    public function testBootstrap()\n    {\n        // If we get to here, then all is well!\n        $this->assertTrue(true);\n    }\n}\n"
  },
  {
    "path": "tests/ValidatorImageAspectTest.php",
    "content": "<?php namespace Cviebrock\\ImageValidator\\Test;\n\nuse Cviebrock\\ImageValidator\\ImageValidator;\nuse Illuminate\\Contracts\\Translation\\Translator;\nuse Mockery;\nuse PHPUnit_Framework_TestCase;\n\n\nclass ValidatorImageAspectTest extends PHPUnit_Framework_TestCase\n{\n\n    protected $translator;\n\n    protected $data;\n\n    protected $rules;\n\n    public function setUp()\n    {\n        $this->translator = Mockery::mock(Translator::class);\n        $this->translator->shouldReceive('trans');\n        $this->data = [\n            'image' => __DIR__ . '/images/200x250.png',\n        ];\n    }\n\n    public function tearDown()\n    {\n        Mockery::close();\n    }\n\n    public function testValidatesAspect()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_aspect:4,5']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesAspectDecimal()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_aspect:0.8']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesReverseAspect()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_aspect:~5,4']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesReverseAspectDecimal()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_aspect:~1.25']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testRoundingAspects()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            ['image' => __DIR__ . '/images/1024x682.png'],\n            ['image' => 'image_aspect:3,2']\n        );\n\n        $this->assertFalse($validator->passes());\n\n        $validator = new ImageValidator(\n            $this->translator,\n            ['image' => __DIR__ . '/images/1024x683.png'],\n            ['image' => 'image_aspect:3,2']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n}\n"
  },
  {
    "path": "tests/ValidatorImageSizeTest.php",
    "content": "<?php namespace Cviebrock\\ImageValidator\\Test;\n\nuse Cviebrock\\ImageValidator\\ImageValidator;\nuse Illuminate\\Contracts\\Translation\\Translator;\nuse Mockery;\nuse PHPUnit_Framework_TestCase;\n\n\nclass ValidatorImageSizeTest extends PHPUnit_Framework_TestCase\n{\n\n    protected $translator;\n\n    protected $data;\n\n    protected $rules;\n\n    public function setUp()\n    {\n        $this->translator = Mockery::mock(Translator::class);\n        $this->translator->shouldReceive('trans');\n        $this->data = [\n            'image' => __DIR__ . '/images/200x250.png',\n        ];\n    }\n\n    public function tearDown()\n    {\n        Mockery::close();\n    }\n\n    public function testValidatesMatch()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:200,250']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesSquare()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:200']\n        );\n\n        $this->assertTrue($validator->fails());\n    }\n\n    public function testValidatesLessThan()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:<200,<250']\n        );\n\n        $this->assertTrue($validator->fails());\n    }\n\n    public function testValidatesLessThanEqual()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:<=200,<=250']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesGreaterThan()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:>200,>250']\n        );\n\n        $this->assertTrue($validator->fails());\n    }\n\n    public function testValidatesGreaterThanEqual()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:>=200,>=250']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesAnySize()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:*,250']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n\n    public function testValidatesRange()\n    {\n        $validator = new ImageValidator(\n            $this->translator,\n            $this->data,\n            ['image' => 'image_size:200-300']\n        );\n\n        $this->assertTrue($validator->passes());\n    }\n}\n"
  }
]