From f2739d28f74eaa1362e4485650a34ce8007c118b Mon Sep 17 00:00:00 2001 From: dmolavi Date: Thu, 19 Aug 2010 08:25:44 +0800 Subject: [PATCH] Initial commit of autorotate module. --- modules/autorotate/helpers/autorotate.php | 49 +++++++++++++++++++ .../autorotate/helpers/autorotate_event.php | 32 ++++++++++++ .../helpers/autorotate_installer.php | 42 ++++++++++++++++ modules/autorotate/module.info | 3 ++ 4 files changed, 126 insertions(+) create mode 100644 modules/autorotate/helpers/autorotate.php create mode 100644 modules/autorotate/helpers/autorotate_event.php create mode 100644 modules/autorotate/helpers/autorotate_installer.php create mode 100644 modules/autorotate/module.info diff --git a/modules/autorotate/helpers/autorotate.php b/modules/autorotate/helpers/autorotate.php new file mode 100644 index 00000000..ddf74b78 --- /dev/null +++ b/modules/autorotate/helpers/autorotate.php @@ -0,0 +1,49 @@ +is_photo() && $item->mime_type == "image/jpeg") { + require_once(MODPATH . "exif/lib/exif.php"); + $exif_raw = read_exif_data_raw($item->file_path(), false); + if (isset($exif_raw['ValidEXIFData'])) { + $orientation = $exif_raw["IFD0"]["Orientation"]; + $degrees = 0; + if ($orientation == '3: Upside-down') { + $degrees = 180; + } + else if ($orientation == '8: 90 deg CW') { + $degrees = -90; + } + else if ($orientation == '6: 90 deg CCW') { + $degrees = 90; + } + if($degrees) { + $tmpfile = tempnam(TMPPATH, "rotate"); + gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees)); + $item->set_data_file($tmpfile); + $item->save(); + unlink($tmpfile); + } + } + } + return; + } +} \ No newline at end of file diff --git a/modules/autorotate/helpers/autorotate_event.php b/modules/autorotate/helpers/autorotate_event.php new file mode 100644 index 00000000..f8307215 --- /dev/null +++ b/modules/autorotate/helpers/autorotate_event.php @@ -0,0 +1,32 @@ +getMessage() . "\n" . $e->getTraceAsString()); + } + } +} \ No newline at end of file diff --git a/modules/autorotate/helpers/autorotate_installer.php b/modules/autorotate/helpers/autorotate_installer.php new file mode 100644 index 00000000..8ae94fda --- /dev/null +++ b/modules/autorotate/helpers/autorotate_installer.php @@ -0,0 +1,42 @@ +