diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2010-08-08 21:17:16 -0700 | 
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2010-08-08 21:17:16 -0700 | 
| commit | 639d31a2c1a54f31ad32208b8602a8922d336fa0 (patch) | |
| tree | 52972083c21e38c7ffaad90abae29dc23b11b527 /modules/g2_import | |
| parent | 58bf479f4c040ac73ea190d966ffd5408f9908f0 (diff) | |
If the imported item from Gallery 2 has a preferred derivative with a
rotation, then rotate the imported image accordingly.  Fixes ticket #1274..
Diffstat (limited to 'modules/g2_import')
| -rw-r--r-- | modules/g2_import/helpers/g2_import.php | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 306a0c50..f2e9dad9 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -588,6 +588,20 @@ class g2_import_Core {          $item->description = self::_decode_html_special_chars(self::extract_description($g2_item));          $item->owner_id = self::map($g2_item->getOwnerId());          $item->save(); + +        // If the item has a preferred derivative with a rotation, then rotate this image +        // accordingly.  Should we obey scale rules as well?  I vote no because rotation is less +        // destructive -- you lose too much data from scaling. +        $g2_preferred = g2(GalleryCoreApi::fetchPreferredSource($g2_item)); +        if ($g2_preferred && $g2_preferred instanceof GalleryDerivative) { +          if (preg_match("/rotate\|(-?\d+)/", $g2_preferred->getDerivativeOperations(), $matches)) { +            $tmpfile = tempnam(TMPPATH, "rotate"); +            gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $matches[1])); +            $item->set_data_file($tmpfile); +            $item->save(); +            unlink($tmpfile); +          } +        }        } catch (Exception $e) {          $exception_info = (string) new G2_Import_Exception(              t("Corrupt image '%path'", array("path" => $g2_path)), | 
