[f-spot/rubenv-gsoc-2009: 36/86] Add a filter to make sure that the exported file is processed.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot/rubenv-gsoc-2009: 36/86] Add a filter to make sure that the exported file is processed.
- Date: Sun, 23 May 2010 12:34:58 +0000 (UTC)
commit eed74cb57155645837b29e62edb06bea3fc1d0f3
Author: Ruben Vermeersch <ruben savanne be>
Date: Wed Jul 29 15:50:54 2009 +0200
Add a filter to make sure that the exported file is processed.
.../Exporters/FacebookExport/FacebookExport.cs | 1 +
extensions/Exporters/FlickrExport/FlickrExport.cs | 1 +
.../Exporters/GalleryExport/GalleryExport.cs | 2 +-
.../Exporters/PicasaWebExport/PicasaWebExport.cs | 2 +
.../Exporters/SmugMugExport/SmugMugExport.cs | 2 +
src/Filters/ProcessedFormatFilter.cs | 55 ++++++++++++++++++++
src/Makefile.am | 1 +
7 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/extensions/Exporters/FacebookExport/FacebookExport.cs b/extensions/Exporters/FacebookExport/FacebookExport.cs
index f7d4c9c..ac065e9 100644
--- a/extensions/Exporters/FacebookExport/FacebookExport.cs
+++ b/extensions/Exporters/FacebookExport/FacebookExport.cs
@@ -343,6 +343,7 @@ namespace FSpot.Exporter.Facebook
FilterSet filters = new FilterSet ();
filters.Add (new JpegFilter ());
filters.Add (new ResizeFilter (size));
+ filters.Add (new ProcessedFormatFilter ());
for (int i = 0; i < items.Length; i++) {
try {
diff --git a/extensions/Exporters/FlickrExport/FlickrExport.cs b/extensions/Exporters/FlickrExport/FlickrExport.cs
index 7ff22c5..1d7a74f 100644
--- a/extensions/Exporters/FlickrExport/FlickrExport.cs
+++ b/extensions/Exporters/FlickrExport/FlickrExport.cs
@@ -353,6 +353,7 @@ namespace FSpotFlickrExport {
FilterSet stack = new FilterSet ();
if (scale)
stack.Add (new ResizeFilter (size));
+ stack.Add (new ProcessedFormatFilter ());
string id = fr.Upload (photo, stack, is_public, is_family, is_friend);
ids.Add (id);
diff --git a/extensions/Exporters/GalleryExport/GalleryExport.cs b/extensions/Exporters/GalleryExport/GalleryExport.cs
index e4c4f8e..6543f0a 100644
--- a/extensions/Exporters/GalleryExport/GalleryExport.cs
+++ b/extensions/Exporters/GalleryExport/GalleryExport.cs
@@ -767,7 +767,7 @@ namespace G2Export {
filters.Add (new ResizeFilter (size));
else if (rotate)
filters.Add (new OrientationFilter ());
-
+ filters.Add (new ProcessedFormatFilter ());
while (photo_index < items.Length) {
IBrowsableItem item = items [photo_index];
diff --git a/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs b/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
index ab2a4c7..31e13df 100644
--- a/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
+++ b/extensions/Exporters/PicasaWebExport/PicasaWebExport.cs
@@ -648,6 +648,8 @@ namespace FSpotGoogleExport {
if (rotate)
filters.Add (new OrientationFilter ());
+ filters.Add (new ProcessedFormatFilter ());
+
Array.Sort (items, new DateComparer ());
while (photo_index < items.Length) {
diff --git a/extensions/Exporters/SmugMugExport/SmugMugExport.cs b/extensions/Exporters/SmugMugExport/SmugMugExport.cs
index fff5e73..b2c011f 100644
--- a/extensions/Exporters/SmugMugExport/SmugMugExport.cs
+++ b/extensions/Exporters/SmugMugExport/SmugMugExport.cs
@@ -555,6 +555,8 @@ namespace FSpotSmugMugExport {
if (rotate)
filters.Add (new OrientationFilter ());
+ filters.Add (new ProcessedFormatFilter ());
+
while (photo_index < items.Length) {
try {
IBrowsableItem item = items[photo_index];
diff --git a/src/Filters/ProcessedFormatFilter.cs b/src/Filters/ProcessedFormatFilter.cs
new file mode 100644
index 0000000..3bdc974
--- /dev/null
+++ b/src/Filters/ProcessedFormatFilter.cs
@@ -0,0 +1,55 @@
+/*
+ * Filters/ProcessedFormatFilter.cs
+ *
+ * Author(s)
+ * Ruben Vermeersch <ruben savanne be>
+ *
+ * This is free software. See COPYING for details.
+ *
+ */
+using FSpot.Imaging;
+using FSpot.Loaders;
+using FSpot.Utils;
+using Gdk;
+using System;
+using System.IO;
+
+namespace FSpot.Filters {
+ public class ProcessedFormatFilter : IFilter {
+ public int JpegQuality { get; set; }
+
+ public ProcessedFormatFilter ()
+ {
+ JpegQuality = 95;
+ }
+
+ public bool Convert (FilterRequest req)
+ {
+ // FIXME this should copy metadata from the original
+ // even when the source is not a jpeg
+ string source = req.Current.LocalPath;
+
+ using (ImageFile img = ImageFile.Create (req.Current)) {
+ Log.Debug ("Got file: {0}, RAW: {1}", req.Current, img is IRawFile);
+ if (!ImageFile.IsRaw (img))
+ return false;
+
+ Pixbuf buffer = null;
+ using (IImageLoader loader = ImageLoader.Create (req.Current)) {
+ loader.Load (ImageLoaderItem.Full);
+ buffer = loader.Full;
+ }
+
+ req.Current = req.TempUri ("jpg");
+ string dest = req.Current.LocalPath;
+
+ byte [] image_data = PixbufUtils.Save (buffer, "jpeg", new string [] {"quality" }, new string [] { JpegQuality.ToString () });
+ using (Stream stream = System.IO.File.OpenWrite (dest)) {
+ stream.Write (image_data, 0, image_data.Length);
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 10947d6..13d18c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -217,6 +217,7 @@ F_SPOT_CSDISTFILES = \
$(srcdir)/Filters/IFilter.cs \
$(srcdir)/Filters/JpegFilter.cs \
$(srcdir)/Filters/OrientationFilter.cs \
+ $(srcdir)/Filters/ProcessedFormatFilter.cs \
$(srcdir)/Filters/ResizeFilter.cs \
$(srcdir)/Filters/SharpFilter.cs \
$(srcdir)/Filters/UniqueNameFilter.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]