Skip to content
Browse files

Storing rotation information in the photo record. #484

  • Loading branch information...
1 parent d5d432c commit a50a2ee7e3175bd08eb791b9ade1df7ac3060fb4 @jmathai jmathai committed Jun 30, 2012
View
2 documentation/schemas/Photo.markdown
@@ -25,6 +25,7 @@ This includes EXIF information from the photo, tags and URLs to all versions of
size: (int), // in kb
width: (int),
height: (int),
+ rotation: (int),
exifOrientation: (int), // degrees
exifCameraMake: (string),
exifCameraModel: (string),
@@ -75,6 +76,7 @@ This includes EXIF information from the photo, tags and URLs to all versions of
* size, Size of the photo rounded to the nearest Kilobyte
* width, Width of the photo in pixels
* height, Height of the photo in pixels
+ * rotation, Degress the user has rotated the photo (0, 90, 180, 270)
* exifOrientation, Rotation of the camera in degrees
* exifCameraMake, Camera make, i.e. Canon
* exifCcameraModel, Camera model, i.e. EOS Rebel
View
2 src/configs/defaults.ini
@@ -1,7 +1,7 @@
[defaults]
theme="beisel2.0"
lastCodeVersion=0.0.0
-currentCodeVersion=2.0.8
+currentCodeVersion=3.0.1
[site]
maintenance=0
View
1 src/configs/upgrade/db/mysql/mysql-base.php
@@ -206,6 +206,7 @@
`size` int(11) DEFAULT NULL,
`width` int(11) DEFAULT NULL,
`height` int(11) DEFAULT NULL,
+ `rotation` enum('0','90','180','270') NOT NULL DEFAULT '0',
`extra` text,
`exif` text,
`latitude` float(10,6) DEFAULT NULL,
View
12 src/libraries/models/Photo.php
@@ -454,20 +454,22 @@ public function transform($id, $transformations)
return false;
}
+ // update the file on the file system and update the db with the path
+ $paths = $this->generatePaths($photo['filenameOriginal']);
+ $updateFields = array('pathBase' => $paths['pathBase']);
foreach($transformations as $trans => $value)
{
switch($trans)
{
case 'rotate':
$this->image->rotate($value);
+ $updateFields['rotation'] = intval(($photo['rotation'] + $value) % 360);
break;
}
}
- // update the file on the file system and update the db with the path
- $paths = $this->generatePaths($photo['filenameOriginal']);
$updateFs = $this->fs->putPhoto($filename, $paths['pathBase']);
- $updateDb = $this->db->postPhoto($id, array('pathBase' => $paths['pathBase']));
+ $updateDb = $this->db->postPhoto($id, $updateFields);
unlink($filename);
@@ -860,8 +862,8 @@ private function readIptc($photo)
private function whitelistParams($attributes)
{
$returnAttrs = array();
- $matches = array('id' => 1,'host' => 1,'appId' => 1,'title' => 1,'description' => 1,'key' => 1,'hash' => 1,'tags' => 1,'size' => 1,'width' => 1,'photo'=>1,
- 'height' => 1,'altitude' => 1, 'latitude' => 1,'longitude' => 1,'views' => 1,'status' => 1,'permission' => 1,'albums'=>1,'groups' => 1,'license' => 1,
+ $matches = array('id' => 1,'host' => 1,'appId' => 1,'title' => 1,'description' => 1,'key' => 1,'hash' => 1,'tags' => 1,'size' => 1,'photo'=>1,'height' => 1,
+ 'rotation'=>1,'altitude' => 1, 'latitude' => 1,'longitude' => 1,'views' => 1,'status' => 1,'permission' => 1,'albums'=>1,'groups' => 1,'license' => 1,
'dateTaken' => 1, 'dateUploaded' => 1, 'filenameOriginal' => 1 /* TODO remove in 1.5.0, only used for upgrade */);
$patterns = array('exif.*','date.*','path.*','extra.*');
foreach($attributes as $key => $val)

0 comments on commit a50a2ee

Please sign in to comment.
Something went wrong with that request. Please try again.