I hope that this will be added in the next release, but so far I added a quickfix to my CPG. You need ImageMagick for it, and it adds a checkbox in the "Edit Pics" page right next to the "Delete Pic" button. Checking this checkbox will rotate your picture 90 degrees to the right (which should suffice in most cases, else repeat as necessary).
The only downside is this function only works if the pictures on the server have the right permissions (which should be the case, normally). Details & Discussion down.
Now the code (This is a 'diff -uraN' of editpics.php, files with + are added. with - are removed)
--- editpics.php.backup Tue Sep 30 173158 2003
+++ editpics.php Thu Oct 2 113301 2003
@@ -102,12 +102,13 @@
$user3 = get_post_var('user3', $pid);
$user4 = get_post_var('user4', $pid);
+ $rotate = isset($HTTP_POST_VARS['rotate'.$pid]);
$delete = isset($HTTP_POST_VARS['delete'.$pid]);
$reset_vcount = isset($HTTP_POST_VARS['reset_vcount'.$pid]);
$reset_votes = isset($HTTP_POST_VARS['reset_votes'.$pid]);
$del_comments = isset($HTTP_POST_VARS['del_comments'.$pid]) || $delete;
- $query = "SELECT category, filepath, filename FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}
.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'";
+ $query = "SELECT category, filepath, filename, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['
TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'";
$result = db_query($query);
if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
$pic = mysql_fetch_array($result);
@@ -162,6 +163,26 @@
$query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET $update WHERE pid='$pid' LIMIT 1";
$result = db_query($query);
}
+
+ if ($rotate) {
+ $dir=$CONFIG['fullpath'].$pic['filepath'];
+ $file=$pic['filename'];
+ if(isset($pic['pwidth'])) $oldwidth=$pic['pwidth'];
+ if(isset($pic['pheight'])) $oldheight=$pic['pheight'];
+
+ if (!is_writable($dir)) cpg_die(CRITICAL_ERROR, sprintf($lang_errors['directory_ro'], $dir), __FILE__, __LINE__);
+
+ $files=array($dir.$file, $dir.$CONFIG['normal_pfx'].$file, $dir.$CONFIG['thumb_pfx'].$file);
+ foreach ($files as $currFile){
+ if (is_file($currFile)) {
+ system("{$CONFIG['impath']}convert -rotate 90 $currFile $currFile");
+ }
+ # php > 4.3.0
+ #if (is_file($currFile)) @ImageRotate($currFile,90,0);
+ }
+ $query = "UPDATE {$CONFIG['TABLE_PICTURES']} SET pwidth='$oldheight', pheight='$oldwidth' WHERE pid='$pid' LIMIT 1";
+ $result = db_query($query);
+ }
}
}
@@ -237,6 +258,7 @@
echo <<<EOT
<tr>
<td class="tableb" colspan="3" align="center">
+ <b><input type="checkbox" name="rotate{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['rotate_pic']}</b> 
;
<b><input type="checkbox" name="delete{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['del_pic']}</b>
<b><input type="checkbox" name="reset_vcount{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['reset_view_count
']}</b>
<b><input type="checkbox" name="reset_votes{$CURRENT_PIC['pid']}" value="1" class="checkbox">{$lang_editpics_php['reset_votes']}</b
>
This is the diff of the english language file (needed if you want to have a labeled button ;) )
--- lang/english.php.backup Tue Sep 30 190905 2003
+++ lang/english.php Tue Sep 30 174532 2003
@@ -528,6 +528,7 @@
'approve' => 'Approve picture',
'postpone_app' => 'Postpone approval',
'del_pic' => 'Delete picture',
+ 'rotate_pic' => 'Rotate picture',
'reset_view_count' => 'Reset view counter',
'reset_votes' => 'Reset votes',
'del_comm' => 'Delete comments',
Details and discussion (for the development team)
I uploaded the pictures via scp and unpacked them into an special made directory reflecting the name of my gallery album, because I hate to have all my pictures in a single directory. As a result. the pictures had my users' permissions (and uid/gid) instead those of the webserver, which resulted in rotated thumbs, but not the original pic.
For the next version, I would appreciate a more flexible approach where pictures are physically stored, e.g. folder names reflecting the album names and maybe the category/album hierarchy. Moving a picture should not only affect the db entry, it should move the file physically, too. It would be cool to have a special "upload" directory, where CPG fetches it's pictures, moves them into the right album folder and creates thumbs there.
So far, and thanks for the great gallery you've made,
/majestyk