diff --git a/DependencyInjection/LiipImagineExtension.php b/DependencyInjection/LiipImagineExtension.php
index 3dd2396c8..908428c43 100644
--- a/DependencyInjection/LiipImagineExtension.php
+++ b/DependencyInjection/LiipImagineExtension.php
@@ -56,6 +56,11 @@ public function load(array $configs, ContainerBuilder $container)
$container->setAlias('liip_imagine', new Alias('liip_imagine.'.$config['driver']));
+ if (!class_exists('Imagine\Image\Metadata\MetadataReaderInterface')) {
+ $container->getDefinition('liip_imagine.'.$config['driver'])->removeMethodCall('setMetadataReader');
+ $container->removeDefinition('liip_imagine.meta_data.reader');
+ }
+
$container->setParameter('liip_imagine.cache.resolver.default', $config['cache']);
$container->setParameter('liip_imagine.filter_sets', $config['filter_sets']);
diff --git a/Imagine/Filter/Loader/AutoRotateFilterLoader.php b/Imagine/Filter/Loader/AutoRotateFilterLoader.php
index 15d6ed6d4..5d9096f09 100644
--- a/Imagine/Filter/Loader/AutoRotateFilterLoader.php
+++ b/Imagine/Filter/Loader/AutoRotateFilterLoader.php
@@ -16,11 +16,8 @@ class AutoRotateFilterLoader implements LoaderInterface
*/
public function load(ImageInterface $image, array $options = array())
{
- $exifData = exif_read_data("data://image/jpeg;base64," . base64_encode($image->get('jpg')));
-
- if (isset($exifData['Orientation'])) {
- $orientation = (int) $exifData['Orientation'];
- $degree = $this->calculateRotation($orientation);
+ if ($orientation = $this->getOrientation($image)) {
+ $degree = $this->calculateRotation((int)$orientation);
if ($degree !== 0) {
$image->rotate($degree);
@@ -55,4 +52,19 @@ private function calculateRotation($orientation)
return $degree;
}
+
+ /**
+ * @param ImageInterface $image
+ * @return int
+ */
+ private function getOrientation(ImageInterface $image)
+ {
+ //>0.6 imagine meta data interface
+ if (method_exists($image, 'metadata')) {
+ return $image->metadata()->offsetGet('exif.Orientation');
+ } else {
+ $data = exif_read_data("data://image/jpeg;base64," . base64_encode($image->get('jpg')));
+ return isset($data['Orientation']) ? $data['Orientation'] : null;
+ }
+ }
}
diff --git a/Resources/config/imagine.xml b/Resources/config/imagine.xml
index 1b3ddcfd5..333ca1314 100644
--- a/Resources/config/imagine.xml
+++ b/Resources/config/imagine.xml
@@ -59,6 +59,7 @@
Liip\ImagineBundle\Form\Type\ImageType
+ Imagine\Image\Metadata\ExifMetadataReader
@@ -98,9 +99,13 @@
+
+
-
+
+
+
diff --git a/composer.json b/composer.json
index cafa8da29..cc1889179 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
},
"require": {
"php": ">=5.3.2",
- "imagine/Imagine": "0.5.*",
+ "imagine/Imagine": "~0.5,<0.7",
"symfony/finder": "~2.3",
"symfony/filesystem": "~2.3",
"symfony/options-resolver": "~2.3",