Re: Export to Gallery2: rotation patch



Hi there,

Please find below a brand-new patch rotating patch. It rotate images for
Gallery2 AND also for regular folder export.
And also the regular screenshots
http://www.delcroix.org/f-spot/rotate-patch.jpg
http://www.delcroix.org/f-spot/FolderExport-rotate-1.jpg
http://www.delcroix.org/f-spot/FolderExport-rotate-2.jpg

Here is open question to the list regarding this patch:
 - Is 'Original' able to read EXIF and rotate photos ? Since the code
for exporting to 'Original' is the same as the one for exporting to
folder, I rotate also images for 'Original'. Could anybody try this
patch with 'Original' ?

To definitely solve the bug
http://bugzilla.gnome.org/show_bug.cgi?id=165645 , I still have to fix
the 'Export to CD' thing.

Stephane

On Sun, 2006-04-09 at 09:50 +0200, Jean-Christophe Dubacq wrote:
> On Fri, Apr 07, 2006 at 05:12:11PM +0200, Stephane Delcroix wrote:
> > Hi guys,
> > 
> > Gallery2 is not yet able to autorotate pictures with information from
> > the EXIF part of the file.
> > So, I made a patch to f-spot to rotate pictures BEFORE exporting them.
> > You just need to check the checkbox (check the screenshot:
> > http://www.delcroix.org/rotate-patch.jpg )
> > The attached patch if against the latest CVS.
> > 
> > Hope it's useful for a lot of gallery2 / f-spot users...
> 
> It is also useful for normal HTML folders export. Check out the problem
> at
> http://www-lipn.univ-paris13.fr/~dubacq/perso/Favoris/DSC_0068_2976.html
> 
> (Disclaimer: I used jpegtran up to recently to rotate my originals, so I
> needed an exported picture made with the Nikon - my casio camera does
> not have the problem - and exported ; there were few of them, so the
> choice of subject is not meant to hurt anybody's feelings).
> 
> It looks like some of it could be shuffled/copied around to make export
> to HTML folders correct. I do not know about "Original export", however.
> _______________________________________________
> F-spot-list mailing list
> F-spot-list gnome org
> http://mail.gnome.org/mailman/listinfo/f-spot-list
> 
-- 
Stephane Delcroix
stephane delcroix org
? FlickrNet/Makefile
? FlickrNet/Makefile.in
? po/stamp-it
? src/f-spot.gladep
? tools/Makefile
? tools/Makefile.in
? tools/NONE
? tools/f-spot-screensaver.desktop
Index: src/FolderExport.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/FolderExport.cs,v
retrieving revision 1.28
diff -u -r1.28 FolderExport.cs
--- src/FolderExport.cs	24 Feb 2006 18:43:31 -0000	1.28
+++ src/FolderExport.cs	16 Apr 2006 19:33:43 -0000
@@ -36,6 +36,7 @@
 
 		//[Glade.Widget] Gtk.CheckButton meta_check;
 		[Glade.Widget] Gtk.CheckButton scale_check;
+		[Glade.Widget] Gtk.CheckButton rotate_check;
 		[Glade.Widget] Gtk.CheckButton open_check;
 		
 		[Glade.Widget] Gtk.RadioButton static_radio;
@@ -52,6 +53,7 @@
 		int photo_index;
 		bool open;
 		bool scale;
+		bool rotate;
 		int size;
 		
 		string description;
@@ -154,6 +156,11 @@
 					System.Console.WriteLine ("Exporting full size image");
 				}
 
+				if (rotate) {
+					System.Console.WriteLine ("Exporting rotated image");
+					gallery.SetRotate();
+				}
+
 				gallery.Description = description;
 
 				gallery.Generate ();
@@ -246,6 +253,7 @@
 			dest = new Gnome.Vfs.Uri (uri_chooser.Uri);
 			open = open_check.Active;
 			scale = scale_check.Active;
+			rotate = rotate_check.Active;
 			gallery_name = name_entry.Text;
 
 			if (description_entry != null)
@@ -274,6 +282,7 @@
 		protected string gallery_path;
 		protected bool scale;
 		protected int size;
+		protected bool rotate;
 		protected string description;
 		protected System.Uri destination;
 
@@ -342,10 +351,12 @@
 			MakeDir (SubdirPath (req.Name));
 			path = SubdirPath (req.Name, ImageName (image_num));
 			
-			if (!scale)
+			if (scale) 
+				PixbufUtils.Resize (photo_path, path, size, true); 	
+			else if (rotate)
+				PixbufUtils.Rotate (photo_path, path, true);
+			else
 				File.Copy(photo_path, path, true);
-			else 
-				PixbufUtils.Resize (photo_path, path, size, true); 
 			
 			Gdk.Pixbuf img = null;
 			Gdk.Pixbuf scaled = null;
@@ -370,7 +381,7 @@
 
 				
 				if (req.CopyExif && data != null) {
-					PixbufUtils.SaveJpeg (scaled, path, 90, data);
+					PixbufUtils.SaveJpeg (scaled, path, 95, data);
 				} else 
 					scaled.Savev (path, "jpeg", pixbuf_keys, pixbuf_values);
 				
@@ -436,6 +447,10 @@
 			this.size = size;
 			requests [0].Width = size;
 			requests [0].Height = size;
+		}
+
+		public void SetRotate () {
+			this.rotate = true;
 		}
 	}
 
Index: src/GalleryExport.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/GalleryExport.cs,v
retrieving revision 1.36
diff -u -r1.36 GalleryExport.cs
--- src/GalleryExport.cs	22 Mar 2006 16:57:27 -0000	1.36
+++ src/GalleryExport.cs	16 Apr 2006 19:33:44 -0000
@@ -497,11 +497,13 @@
 			LoadPreference (Preferences.EXPORT_GALLERY_SIZE);
 			LoadPreference (Preferences.EXPORT_GALLERY_BROWSER);
 			LoadPreference (Preferences.EXPORT_GALLERY_META);
+			LoadPreference (Preferences.EXPORT_GALLERY_ROTATE);
 		}
 		
 		Gtk.ResponseHandler rh;
 		
 		private bool scale;
+		private bool rotate;
 		private int size;
 		private bool browser;
 		private bool meta;
@@ -531,6 +533,7 @@
 		[Glade.Widget] Gtk.CheckButton browser_check;
 		[Glade.Widget] Gtk.CheckButton scale_check;
 		[Glade.Widget] Gtk.CheckButton meta_check;
+		[Glade.Widget] Gtk.CheckButton rotate_check;
 		
 		[Glade.Widget] Gtk.SpinButton size_spin;
 
@@ -560,6 +563,7 @@
 
 			browser = browser_check.Active;
 			meta = meta_check.Active;
+			rotate = rotate_check.Active;
 
 			if (account != null) { 
 				//System.Console.WriteLine ("history = {0}", album_optionmenu.History);
@@ -579,6 +583,7 @@
 				Preferences.Set (Preferences.EXPORT_GALLERY_SIZE, size);
 				Preferences.Set (Preferences.EXPORT_GALLERY_BROWSER, browser);
 				Preferences.Set (Preferences.EXPORT_GALLERY_META, meta);
+				Preferences.Set (Preferences.EXPORT_GALLERY_ROTATE, rotate);
 			}
 		}
 		
@@ -619,6 +624,14 @@
 						System.IO.File.Move (path, final);
 						album.Add (photo, final);
 						System.IO.File.Delete (final);
+					} else if (rotate) {
+						string orig = photo.DefaultVersionUri.LocalPath;
+						string path = PixbufUtils.Rotate (orig, true);
+						string final = path + System.IO.Path.GetExtension (orig);
+						System.IO.File.Move (path, final);
+						album.Add (photo, final);
+						System.IO.File.Delete (final);
+						
 					} else {
 						album.Add (photo);
 					}
@@ -794,6 +807,10 @@
 			case Preferences.EXPORT_GALLERY_META:
 				if (meta_check.Active != (bool) val)
 					meta_check.Active = (bool) val;
+				break;
+			case Preferences.EXPORT_GALLERY_ROTATE:
+				if (rotate_check.Active != (bool) val)
+					rotate_check.Active = (bool) val;
 				break;
 			}
 		}
Index: src/PixbufUtils.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/PixbufUtils.cs,v
retrieving revision 1.69
diff -u -r1.69 PixbufUtils.cs
--- src/PixbufUtils.cs	28 Feb 2006 17:50:22 -0000	1.69
+++ src/PixbufUtils.cs	16 Apr 2006 19:33:45 -0000
@@ -424,8 +424,28 @@
 		Gdk.Pixbuf image = PixbufUtils.LoadAtMaxSize (orig_path, size, size);
 		PixbufUtils.SaveJpeg (image, dest_path, 95, exif_data);
 	}
-	
 
+	public static string Rotate (string orig_path, bool copy_meta)
+	{
+		string version_path = System.IO.Path.GetTempFileName ();
+		Rotate (orig_path, version_path, copy_meta);
+		return version_path;
+	}
+		
+	public static void Rotate (string orig_path, string dest_path, bool copy_meta)
+	{
+		Exif.ExifData exif_data;
+		if (copy_meta)
+			exif_data = new Exif.ExifData (orig_path);
+		else 
+			exif_data = new Exif.ExifData ();
+		
+		PixbufOrientation orientation = GetOrientation (exif_data);
+		Gdk.Pixbuf orig = new Gdk.Pixbuf(orig_path);
+		Gdk.Pixbuf image = PixbufUtils.TransformOrientation (orig, orientation, copy_meta);
+		PixbufUtils.SaveJpeg (image, dest_path, 95, exif_data);
+	}
+	
 	[StructLayout(LayoutKind.Sequential)]
 	public unsafe struct FPixbufJpegMarker {
 		public int type;
Index: src/Preferences.cs
===================================================================
RCS file: /cvs/gnome/f-spot/src/Preferences.cs,v
retrieving revision 1.12
diff -u -r1.12 Preferences.cs
--- src/Preferences.cs	22 Mar 2006 23:53:36 -0000	1.12
+++ src/Preferences.cs	16 Apr 2006 19:33:45 -0000
@@ -70,6 +70,7 @@
 		public const string EXPORT_GALLERY_SIZE = "/apps/f-spot/export/gallery/size";
 		public const string EXPORT_GALLERY_BROWSER = "/apps/f-spot/export/gallery/browser";
 		public const string EXPORT_GALLERY_META = "/apps/f-spot/export/gallery/meta";
+		public const string EXPORT_GALLERY_ROTATE = "/apps/f-spot/export/gallery/rotate";
 
 		public const string SCREENSAVER_TAG = "/apps/f-spot/screensaver/tag_id";
 
Index: src/f-spot.glade
===================================================================
RCS file: /cvs/gnome/f-spot/src/f-spot.glade,v
retrieving revision 1.159
diff -u -r1.159 f-spot.glade
--- src/f-spot.glade	25 Feb 2006 08:54:05 -0000	1.159
+++ src/f-spot.glade	16 Apr 2006 19:34:10 -0000
@@ -3694,6 +3694,25 @@
 			      <property name="fill">False</property>
 			    </packing>
 			  </child>
+
+			  <child>
+			    <widget class="GtkCheckButton" id="rotate_check">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">Autorotate</property>
+			      <property name="use_underline">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			      <property name="active">True</property>
+			      <property name="inconsistent">False</property>
+			      <property name="draw_indicator">True</property>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
+			    </packing>
+			  </child>
 			</widget>
 		      </child>
 		    </widget>
@@ -10273,6 +10292,26 @@
 			      <property name="padding">0</property>
 			      <property name="expand">True</property>
 			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkCheckButton" id="rotate_check">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">Autorotate </property>
+			      <property name="use_underline">True</property>
+			      <property name="relief">GTK_RELIEF_NORMAL</property>
+			      <property name="focus_on_click">True</property>
+			      <property name="active">False</property>
+			      <property name="inconsistent">False</property>
+			      <property name="draw_indicator">True</property>
+			      <signal name="toggled" handler="HandleSizeActive" last_modification_time="Sat, 12 Feb 2005 10:29:48 GMT"/>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">False</property>
+			      <property name="fill">False</property>
 			    </packing>
 			  </child>
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]