diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c359b56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +composer.lock +vendor/* +koharness_bootstrap.php + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1313e37 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - composer install --prefer-dist + - vendor/bin/koharness + +script: + - cd /tmp/koharness && ./vendor/bin/phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php + +notifications: + email: false diff --git a/README.markdown b/README.markdown index e69de29..7e03525 100644 --- a/README.markdown +++ b/README.markdown @@ -0,0 +1,6 @@ +# Kohana - image processing module + +| ver | Stable | Develop | +|-------|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------| +| 3.3.x | [![Build Status - 3.3/master](https://travis-ci.org/kohana/image.svg?branch=3.3%2Fmaster)](https://travis-ci.org/kohana/image) | [![Build Status - 3.3/develop](https://travis-ci.org/kohana/image.svg?branch=3.3%2Fdevelop)](https://travis-ci.org/kohana/image) | +| 3.4.x | [![Build Status - 3.4/master](https://travis-ci.org/kohana/image.svg?branch=3.4%2Fmaster)](https://travis-ci.org/kohana/image) | [![Build Status - 3.4/develop](https://travis-ci.org/kohana/image.svg?branch=3.4%2Fdevelop)](https://travis-ci.org/kohana/image) | diff --git a/classes/Kohana/Image.php b/classes/Kohana/Image.php index 3fe91fc..b67e6a6 100644 --- a/classes/Kohana/Image.php +++ b/classes/Kohana/Image.php @@ -23,6 +23,7 @@ abstract class Kohana_Image { const VERTICAL = 0x12; /** + * @deprecated - provide an image.default_driver value in your configuration instead * @var string default driver: GD, ImageMagick, etc */ public static $default_driver = 'GD'; @@ -44,8 +45,9 @@ public static function factory($file, $driver = NULL) { if ($driver === NULL) { - // Use the default driver - $driver = Image::$default_driver; + // Use the driver from configuration file or default one + $configured_driver = Kohana::$config->load('image.default_driver'); + $driver = ($configured_driver) ? $configured_driver : Image::$default_driver; } // Set the class name diff --git a/classes/Kohana/Image/GD.php b/classes/Kohana/Image/GD.php index e9c7988..5b52cab 100644 --- a/classes/Kohana/Image/GD.php +++ b/classes/Kohana/Image/GD.php @@ -611,6 +611,7 @@ protected function _save_function($extension, & $quality) switch (strtolower($extension)) { case 'jpg': + case 'jpe': case 'jpeg': // Save a JPG file $save = 'imagejpeg'; diff --git a/classes/Kohana/Image/Imagick.php b/classes/Kohana/Image/Imagick.php index 21adbbf..aa060c2 100644 --- a/classes/Kohana/Image/Imagick.php +++ b/classes/Kohana/Image/Imagick.php @@ -314,6 +314,7 @@ protected function _get_imagetype($extension) switch ($format) { case 'jpg': + case 'jpe': case 'jpeg': $type = IMAGETYPE_JPEG; break; diff --git a/composer.json b/composer.json index ed5cae4..a5c6049 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,11 @@ "kohana/core": ">=3.3", "php": ">=5.3.3" }, + "require-dev": { + "kohana/core": "3.3.*@dev", + "kohana/unittest": "3.3.*@dev", + "kohana/koharness": "*@dev" + }, "suggest": { "ext-gd": "*" }, @@ -31,6 +36,9 @@ "branch-alias": { "dev-3.3/develop": "3.3.x-dev", "dev-3.4/develop": "3.4.x-dev" - } + }, + "installer-paths": { + "vendor/{$vendor}/{$name}": ["type:kohana-module"] + } } } diff --git a/config/image.php b/config/image.php new file mode 100644 index 0000000..2d8bb04 --- /dev/null +++ b/config/image.php @@ -0,0 +1,8 @@ + NULL, +); diff --git a/guide/image/index.md b/guide/image/index.md index 0225c26..dd1e6b8 100644 --- a/guide/image/index.md +++ b/guide/image/index.md @@ -4,7 +4,24 @@ Kohana 3.x provides a simple yet powerful image manipulation module. The [Image] ## Drivers -[Image] module ships with [Image_GD] driver which requires `GD` extension enabled in your PHP installation. This is the default driver. Additional drivers can be created by extending the [Image] class. +[Image] module ships with [Image_GD] driver which requires `GD` extension enabled in your PHP installation, and +[Image_Imagick] driver which requires the `imagick` PHP extension. Additional drivers can be created by extending +the [Image] class. + +The [Image_GD] driver is the default. You can change this by providing an `image.default_driver` configuration option +- for example: + +~~~ +// application/config/image.php + 'Imagick' +); +~~~ + +[!!] Older versions of Kohana allowed you to configure the driver with the `Image::$default_driver` static variable in +the bootstrap, an extension class, or elsewhere. That variable is now deprecated and will be ignored if you set a +config value. ## Getting Started @@ -18,4 +35,4 @@ Kohana::modules(array( )); ~~~ -Next: [Using the image module](using). \ No newline at end of file +Next: [Using the image module](using). diff --git a/koharness.php b/koharness.php new file mode 100644 index 0000000..fc5e95a --- /dev/null +++ b/koharness.php @@ -0,0 +1,8 @@ + array( + 'image' => __DIR__, + 'unittest' => __DIR__ . '/vendor/kohana/unittest' + ), +);