Auto-rotate in Gallery Remote?

trumpetlips
trumpetlips's picture

Joined: 2003-07-24
Posts: 5
Posted: Thu, 2003-07-24 14:31

Yes, I read the recent Rotate in GR thread... I don't want to manually rotate them. Will auto-rotation be included in any future builds of Gallery Remote? Just wondering, since the EXIF data is there and uploading from the web interface does it...

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Thu, 2003-07-24 14:42

Have a look at tjhe [URL=http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/gallery/gallery_remote/roadmap.html]GR Roadmap[/URL]

 
paour
paour's picture

Joined: 2002-08-14
Posts: 1479
Posted: Thu, 2003-07-24 15:02

h0bbel meant to point to [url=http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/gallery/gallery_remote/features.html]this URL[/url]...

And this feature is not in the roadmap yet. I think it would be good to handle auto-rotate. I'll have to figure out how to read the EXIF from Java (advice gratefully accepted).

I'll add the feature to the roadmap now.

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Thu, 2003-07-24 15:31
 
trumpetlips
trumpetlips's picture

Joined: 2003-07-24
Posts: 5
Posted: Thu, 2003-07-31 15:44

Or better yet, why not just add the auto-rotate code into gallery_remote2.php - works wonders! (not sure why this wasn't in there to begin with, actually! :wink:)

patch follows (save as upatch.autorotate.txt - copy to your /path/to/gallery directory and execute run patch < upatch.autorotate.txt)

--- gallery_remote2.php Thu Jul 31 10:30:54 2003
+++ gallery_remote2_autorotate.php      Thu Jul 31 10:30:59 2003
@@ -464,6 +464,33 @@
                            $gallery->album->resizePhoto($index, $gallery->album->fields["resize_size"]);
                        }
                    }
+                    /* insert auto-rotate */
+                    /* auto-rotate the photo if needed */
+                   if (!strcmp($gallery->app->autorotate, 'yes') && $gallery->app->use_exif) {
+                           $index = $gallery->album->numPhotos(1);
+                           $exifData = $gallery->album->getExif($index);
+                           if ($orientation = trim($exifData['Orientation'])) {
+                                   $photo = $gallery->album->getPhoto($index);
+                                   switch ($orientation) {
+                                   case "rotate 90":
+                                           $rotate = -90;
+                                           break;
+                                   case "rotate 180":       
+                                           $rotate = 180;
+                                           break;
+                                   case "rotate 270":
+                                           $rotate = 90;
+                                           break;
+                                   default:
+                                           $rotate = 0;
+                                   }
+                                   if ($rotate) {
+                                           $gallery->album->rotatePhoto($index, $rotate);
+                                           processingMsg("- Photo auto-rotated ${rotate}&");
+                                   }
+                           }
+                   }
+                  /* end auto-rotate */
                } else {
                        $error = "$err";
                }
 
paour
paour's picture

Joined: 2002-08-14
Posts: 1479
Posted: Thu, 2003-07-31 15:56

Great, but... what happens if the user manually rotates the pic in GR? I need to add a flag (either a global GR pref or an image per image flag) to tell G to enable or not the auto-rotate.

Do you guys think this would be the way to go? Ultimately I'll probably want to do something in GR anyway, but this is a good solution in the interim. Thanks for making it easy!

That said, I have a high workload over the next 3 weeks, so I will probably not be able to do it until that's over.

 
Warren
Warren's picture

Joined: 2002-07-24
Posts: 794
Posted: Thu, 2003-07-31 16:02
paour wrote:
Do you guys think this would be the way to go?

I'd like both but currently my camera does not do rotation exif info if that is what this auto rotate is dependant on.

How many ppl have cameras that have this exif feature?

 
trumpetlips
trumpetlips's picture

Joined: 2003-07-24
Posts: 5
Posted: Thu, 2003-07-31 21:33
paour wrote:
Thanks for making it easy!

No problem - glad to contribute, no matter how small!

paour wrote:
Great, but... what happens if the user manually rotates the pic in GR? I need to add a flag (either a global GR pref or an image per image flag) to tell G to enable or not the auto-rotate.

If they're manually rotating, then they (most likely) don't have a camera that writes orientation data to the exif header. Perhaps just a quick peek at the exif header, and if there is orientation data, display an alert "this image will be auto-rotated"...

Anyways, you'd have to turn on both $gallery->app->autorotate and use_exif in config.php (or the setup/config wizard), or this addition/hack just doesn't run.

Perhaps autorotate should be turned off by default in config_data.inc instead of being turned on ?? IMHO, most people don't read/change things in the setup/config wizard that they don't specifically have reason to... (i.e. if it's off by default, it doesn't create problems with rotation in GR)

Or split the gallery_remote2.php functionality into a version for the web uploads, and a version for the GR application uploads (gallery_remote2_web.php and gallery_remote2_java.php???) and let the user choose?

Warren wrote:
How many ppl have cameras that have this exif feature?

I do :grin: (Canon Powershot S45)

I think I might be getting kind of ranty, so... I'm going to use the autorotation bit, as it makes more sense to me to let the code do the work for me. I'll be interested to see how this all pans out in GR.

Keep up the excellent work, all!!! :P

 
roachdr504

Joined: 2006-10-17
Posts: 9
Posted: Tue, 2006-10-17 17:13

How would you apply this patch in Windows? Is this patching Gallery2 or Gallery Remote?

Thanks,
Dennis