Пример #1
0
        private bool DelayedUpdateHistogram()
        {
            if (Photos.Length == 0)
            {
                return(false);
            }

            Photo photo = Photos[0];

            Gdk.Pixbuf hint = histogram_hint;
            histogram_hint = null;

            try {
                if (hint == null)
                {
                    using (ImageFile img = ImageFile.Create(photo.DefaultVersionUri))
                        hint = img.Load(256, 256);
                }

                int max = histogram_expander.Allocation.Width;
                histogram_image.Pixbuf = histogram.Generate(hint, max);

                hint.Dispose();
            } catch (System.Exception e) {
                Log.Debug(e.StackTrace);
            }

            return(false);
        }
Пример #2
0
    protected virtual void ProcessRequest(RequestItem request)
    {
        Pixbuf orig_image;

        try {
            using (var img = ImageFile.Create(request.Uri)) {
                if (request.Width > 0)
                {
                    orig_image = img.Load(request.Width, request.Height);
                }
                else
                {
                    orig_image = img.Load();
                }
            }
        } catch (GLib.GException e) {
            Log.Exception(e);
            return;
        }

        if (orig_image == null)
        {
            return;
        }

        request.Result = orig_image;
    }
        public bool Convert(FilterRequest req)
        {
            string source = req.Current.LocalPath;
            Uri    dest   = req.TempUri(Path.GetExtension(source));

            using (ImageFile img = ImageFile.Create(source)) {
                using (Pixbuf pixbuf = img.Load()) {
                    using (ImageInfo info = new ImageInfo(pixbuf)) {
                        MemorySurface surface = new MemorySurface(Format.Argb32,
                                                                  pixbuf.Width,
                                                                  pixbuf.Height);

                        Context ctx = new Context(surface);
                        ctx.Matrix = info.Fill(info.Bounds, angle);
                        Pattern p = new SurfacePattern(info.Surface);
                        ctx.Source = p;
                        ctx.Paint();
                        ((IDisposable)ctx).Dispose();
                        p.Destroy();
                        using (Pixbuf result = CairoUtils.CreatePixbuf(surface)) {
                            using (Stream output = File.OpenWrite(dest.LocalPath)) {
                                img.Save(result, output);
                            }
                        }
                        surface.Flush();
                        info.Dispose();
                        req.Current = dest;
                        return(true);
                    }
                }
            }
        }
            public void Desaturate(string name)
            {
                Profile adjustment = Profile.CreateAbstract(10,
                                                            1.0,
                                                            0.0,
                                                            0.0,
                                                            0.0,
                                                            -100.0,
                                                            null,
                                                            ColorCIExyY.D50,
                                                            ColorCIExyY.D50);

                string path = CreateFile(name, 32);

                using (FilterRequest req = new FilterRequest(path)) {
                    IFilter filter = new ColorFilter(adjustment);
                    Assert.IsTrue(filter.Convert(req), "Filter failed to operate");
                    req.Preserve(req.Current);
                    Assert.IsTrue(System.IO.File.Exists(req.Current.LocalPath),
                                  "Error: Did not create " + req.Current);
                    Assert.IsTrue(new FileInfo(req.Current.LocalPath).Length > 0,
                                  "Error: " + req.Current + "is Zero length");
                    using (ImageFile img = ImageFile.Create(req.Current)) {
                        Pixbuf pixbuf = img.Load();
                        Assert.IsNotNull(pixbuf);
                    }
                }
            }
Пример #5
0
        private bool DelayedUpdateHistogram()
        {
            if (Photos.Length == 0)
            {
                return(false);
            }

            IPhoto photo = Photos[0];

            Gdk.Pixbuf hint = histogram_hint;
            histogram_hint = null;
            int max = histogram_expander.Allocation.Width;

            try {
                if (hint == null)
                {
                    using (var img = ImageFile.Create(photo.DefaultVersion.Uri)) {
                        hint = img.Load(256, 256);
                    }
                }

                histogram_image.Pixbuf = histogram.Generate(hint, max);

                hint.Dispose();
            } catch (System.Exception e) {
                Hyena.Log.Debug(e.StackTrace);
                using (Gdk.Pixbuf empty = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 256, 256)) {
                    empty.Fill(0x0);
                    histogram_image.Pixbuf = histogram.Generate(empty, max);
                }
            }

            return(false);
        }
        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(source)) {
                if (img is JpegFile)
                {
                    return(false);
                }

                req.Current = req.TempUri("jpg");
                string dest = req.Current.LocalPath;

                Exif.ExifData exif_data;
                try {
                    exif_data = new Exif.ExifData(source);
                } catch (Exception) {
                    exif_data = new Exif.ExifData();
                }

                PixbufUtils.SaveJpeg(img.Load(), dest, (int)quality, exif_data);
            }

            return(true);
        }
        public bool Convert(FilterRequest req)
        {
            Uri source = req.Current;

            using (ImageFile img = ImageFile.Create(source)) {
                pixbuf  = img.Load();
                profile = img.GetProfile();

                // If the image doesn't have an embedded profile assume it is sRGB
                if (profile == null)
                {
                    profile = Profile.CreateStandardRgb();
                }

                if (destination == null)
                {
                    destination = profile;
                }

                Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,
                                                  false, 8,
                                                  pixbuf.Width,
                                                  pixbuf.Height);

                Profile [] list = Prepare(pixbuf);

                if (pixbuf.HasAlpha)
                {
                    Gdk.Pixbuf alpha     = PixbufUtils.Flatten(pixbuf);
                    Transform  transform = new Transform(list,
                                                         PixbufUtils.PixbufCmsFormat(alpha),
                                                         PixbufUtils.PixbufCmsFormat(final),
                                                         rendering_intent, 0x0000);
                    PixbufUtils.ColorAdjust(alpha, final, transform);
                    PixbufUtils.ReplaceColor(final, pixbuf);
                    alpha.Dispose();
                    final.Dispose();
                    final = pixbuf;
                }
                else
                {
                    Transform transform = new Transform(list,
                                                        PixbufUtils.PixbufCmsFormat(pixbuf),
                                                        PixbufUtils.PixbufCmsFormat(final),
                                                        rendering_intent, 0x0000);
                    PixbufUtils.ColorAdjust(pixbuf, final, transform);
                    pixbuf.Dispose();
                }

                Uri dest_uri = req.TempUri(Path.GetExtension(source.LocalPath));
                using (Stream output = File.OpenWrite(dest_uri.LocalPath)) {
                    img.Save(final, output);
                }
                final.Dispose();
                req.Current = dest_uri;

                return(true);
            }
        }
Пример #8
0
 public ImageInfo(SafeUri uri)
 {
     using (var img = ImageFile.Create(uri)) {
         Pixbuf pixbuf = img.Load();
         SetPixbuf(pixbuf);
         pixbuf.Dispose();
     }
 }
Пример #9
0
 static public Gdk.Pixbuf LoadAtMaxSize(IBrowsableItem item, int width, int height)
 {
     using (ImageFile img = ImageFile.Create(item.DefaultVersionUri)) {
         Gdk.Pixbuf pixbuf = img.Load(width, height);
         ValidateThumbnail(item.DefaultVersionUri, pixbuf);
         return(pixbuf);
     }
 }
Пример #10
0
 protected void LoadPhoto(Photo photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile)
 {
     // FIXME: We might get this value from the PhotoImageView.
     using (ImageFile img = ImageFile.Create(photo.DefaultVersionUri)) {
         photo_pixbuf  = img.Load();
         photo_profile = img.GetProfile();
     }
 }
Пример #11
0
 static public Gdk.Pixbuf Load(IBrowsableItem item)
 {
     using (ImageFile img = ImageFile.Create(item.DefaultVersionUri)) {
         Gdk.Pixbuf pixbuf = img.Load();
         ValidateThumbnail(item, pixbuf);
         return(pixbuf);
     }
 }
Пример #12
0
 public bool TryCreateThumbnail(SafeUri thumbnailUri, ThumbnailSize size)
 {
     try {
         var imageFile = ImageFile.Create(fileUri);
         return(CreateThumbnail(thumbnailUri, size, imageFile));
     }
     catch {
         return(false);
     }
 }
Пример #13
0
        public override Widget ConfigurationWidget()
        {
            int max;

            using (var img = ImageFile.Create(State.Items[0].DefaultVersion.Uri))
                using (Pixbuf p = img.Load())
                    max = Math.Max(p.Width, p.Height);

            size       = new SpinButton(128, max, 10);
            size.Value = max;
            return(size);
        }
Пример #14
0
        private void HandleApply(object sender, EventArgs args)
        {
            BrowsablePointer item   = view.Item;
            EditTarget       target = new EditTarget(item);

            try {
                using (ImageFile img = ImageFile.Create(item.Current.DefaultVersionUri)) {
                    Cairo.Format format = view.CompletePixbuf().HasAlpha ? Cairo.Format.Argb32 : Cairo.Format.Rgb24;

                    MemorySurface dest = new MemorySurface(format,
                                                           info.Bounds.Width,
                                                           info.Bounds.Height);

                    Context ctx = new Context(dest);
                    effect.OnExpose(ctx, info.Bounds);
                    ((IDisposable)ctx).Dispose();

                    string tmp = ImageFile.TempPath(item.Current.DefaultVersionUri.LocalPath);
                    using (Gdk.Pixbuf output = Widgets.CairoUtils.CreatePixbuf(dest)) {
                        using (System.IO.Stream stream = System.IO.File.OpenWrite(tmp)) {
                            img.Save(output, stream);
                        }
                    }

                    dest.Destroy();

                    // FIXME Not this again. I need to imlplement a real version of the transfer
                    // function that shows progress in the main window and allows for all the
                    // goodies we'll need.
                    Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
                    result = Gnome.Vfs.Xfer.XferUri(new Gnome.Vfs.Uri(UriList.PathToFileUri(tmp).ToString()),
                                                    new Gnome.Vfs.Uri(target.Uri.ToString()),
                                                    Gnome.Vfs.XferOptions.Default,
                                                    Gnome.Vfs.XferErrorMode.Abort,
                                                    Gnome.Vfs.XferOverwriteMode.Replace,
                                                    delegate {
                        System.Console.Write(".");
                        return(1);
                    });

                    target.Commit();
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                target.Delete();
                Dialog d = new EditExceptionDialog((Gtk.Window)view.Toplevel, e, view.Item.Current);
                d.Show();
                d.Run();
                d.Destroy();
            }
            Destroy();
        }
Пример #15
0
        public GoogleAccountDialog(Gtk.Window parent, GoogleAccount account, bool show_error, CaptchaException captcha_exception)
        {
            xml = new Glade.XML(null, "PicasaWebExport.glade", dialog_name, "f-spot");
            xml.Autoconnect(this);
            Dialog.Modal           = false;
            Dialog.TransientFor    = parent;
            Dialog.DefaultResponse = Gtk.ResponseType.Ok;

            this.account = account;

            bool show_captcha = (captcha_exception != null);

            status_area.Visible   = show_error;
            locked_area.Visible   = show_captcha;
            captcha_label.Visible = show_captcha;
            captcha_entry.Visible = show_captcha;
            captcha_image.Visible = show_captcha;

            password_entry.ActivatesDefault = true;
            username_entry.ActivatesDefault = true;

            if (show_captcha)
            {
                try {
                    using  (ImageFile img = ImageFile.Create(new Uri(captcha_exception.CaptchaUrl))) {
                        captcha_image.Pixbuf = img.Load();
                        token = captcha_exception.Token;
                    }
                } catch (Exception) {}
            }

            if (account != null)
            {
                password_entry.Text = account.Password;
                username_entry.Text = account.Username;
                add_button.Label    = Gtk.Stock.Ok;
                Dialog.Response    += HandleEditResponse;
            }

            if (remove_button != null)
            {
                remove_button.Visible = account != null;
            }

            this.Dialog.Show();

            password_entry.Changed += HandleChanged;
            username_entry.Changed += HandleChanged;
            HandleChanged(null, null);
        }
Пример #16
0
        public bool Convert(FilterRequest req)
        {
            var dest_uri = req.TempUri(req.Current.GetExtension());

            using (var img = ImageFile.Create(req.Current)) {
                using (Pixbuf in_pixbuf = img.Load()) {
                    using (Pixbuf out_pixbuf = PixbufUtils.UnsharpMask(in_pixbuf, radius, amount, threshold, null)) {
                        PixbufUtils.CreateDerivedVersion(req.Current, dest_uri, 95, out_pixbuf);
                    }
                }
            }

            req.Current = dest_uri;
            return(true);
        }
Пример #17
0
    public void SubSecondsOriginal_tag_gets_converted_to_milliseconds(
        string subSecondsTagValue,
        int expectedMilliseconds)
    {
        var exifTags = new[]
        {
            new TestTag(0x9003, "2021:04:05 10:56:13"),
            new TestTag(0x9291, subSecondsTagValue)
        };

        var sut = ImageFile.Create(new CameraFilePath("file.jpg"), exifTags).Value;

        var expected = new DateTime(2021, 04, 05, 10, 56, 13).AddMilliseconds(expectedMilliseconds);

        sut.Created.Should().Be(expected);
    }
        public bool Convert(FilterRequest req)
        {
            string source = req.Current.LocalPath;

            System.Uri dest_uri = req.TempUri(System.IO.Path.GetExtension(source));
            string     dest     = dest_uri.LocalPath;

            using (ImageFile img = ImageFile.Create(source)) {
                using (Pixbuf pixbuf = img.Load()) {
                    if (pixbuf.Width < size && pixbuf.Height < size)
                    {
                        return(false);
                    }
                }

                using (Pixbuf pixbuf = img.Load((int)size, (int)size)) {
                    string destination_extension = Path.GetExtension(dest);

                    if (Path.GetExtension(source).ToLower() == Path.GetExtension(dest).ToLower())
                    {
                        using (Stream output = File.OpenWrite(dest)) {
                            img.Save(pixbuf, output);
                        }
                    }
                    else if (destination_extension == ".jpg")
                    {
                        // FIXME this is a bit of a nasty hack to work around
                        // the lack of being able to change the path in this filter
                        // and the lack of proper metadata copying yuck
                        Exif.ExifData exif_data;

                        exif_data = new Exif.ExifData(source);

                        PixbufUtils.SaveJpeg(pixbuf, dest, 95, exif_data);
                    }
                    else
                    {
                        throw new NotImplementedException(String.Format(Catalog.GetString("No way to save files of type \"{0}\""), destination_extension));
                    }
                }
            }

            req.Current = dest_uri;
            return(true);
        }
Пример #19
0
    public static void CreateDerivedVersion(SafeUri source, SafeUri destination, uint jpeg_quality = 95)
    {
        if (source.GetExtension() == destination.GetExtension())
        {
            // Simple copy will do!
            var file_from = GLib.FileFactory.NewForUri(source);
            var file_to   = GLib.FileFactory.NewForUri(destination);
            file_from.Copy(file_to, GLib.FileCopyFlags.AllMetadata | GLib.FileCopyFlags.Overwrite, null, null);
            return;
        }

        // Else make a derived copy with metadata copied
        using (var img = ImageFile.Create(source)) {
            using (var pixbuf = img.Load()) {
                CreateDerivedVersion(source, destination, jpeg_quality, pixbuf);
            }
        }
    }
            public void Process(string name)
            {
                string path = CreateFile(name, 120);

                using (FilterRequest req = new FilterRequest(path)) {
                    IFilter filter = new AutoStretch();
                    Assert.IsTrue(filter.Convert(req), "Filter failed to operate");
                    Assert.IsTrue(System.IO.File.Exists(req.Current.LocalPath),
                                  "Error: Did not create " + req.Current.LocalPath);
                    Assert.IsTrue(new FileInfo(req.Current.LocalPath).Length > 0,
                                  "Error: " + req.Current.LocalPath + "is Zero length");
                    //req.Preserve (req.Current);
                    using (ImageFile img = ImageFile.Create(req.Current)) {
                        Pixbuf pixbuf = img.Load();
                        Assert.IsNotNull(pixbuf);
                    }
                }
            }
Пример #21
0
        public bool Import(Photo photo, string path, string orig_path)
        {
            XmpFile xmp;

            string source_sidecar = String.Format("{0}{1}{2}.xmp",
                                                  Path.GetDirectoryName(orig_path),
                                                  Path.DirectorySeparatorChar,
                                                  Path.GetFileName(orig_path));

            string dest_sidecar = String.Format("{0}{1}{2}.xmp",
                                                Path.GetDirectoryName(path),
                                                Path.DirectorySeparatorChar,
                                                Path.GetFileName(path));

            if (File.Exists(source_sidecar))
            {
                xmp = new XmpFile(File.OpenRead(source_sidecar));
            }
            else if (File.Exists(dest_sidecar))
            {
                xmp = new XmpFile(File.OpenRead(dest_sidecar));
            }
            else
            {
                xmp = new XmpFile();
            }

            using (ImageFile img = ImageFile.Create(path)) {
                StatementSource source = img as StatementSource;
                if (source != null)
                {
                    try {
                        source.Select(xmp);
                    } catch  {
                    }
                }
            }

            ProcessStore(xmp.Store, photo);
#if enable_debug
            xmp.Save(Console.OpenStandardOutput());
#endif
            return(true);
        }
Пример #22
0
        void LoadNext()
        {
            if (next != null)
            {
                next = null;
            }

            if (item == null || item.Current == null)
            {
                return;
            }

            using (var img = ImageFile.Create(item.Current.DefaultVersion.Uri)) {
                try {
                    using (var pb = img.Load()) {
                        double scale = Math.Min((double)Allocation.Width / (double)pb.Width, (double)Allocation.Height / (double)pb.Height);
                        int    w     = (int)(pb.Width * scale);
                        int    h     = (int)(pb.Height * scale);

                        if (w > 0 && h > 0)
                        {
                            next = pb.ScaleSimple((int)(pb.Width * scale), (int)(pb.Height * scale), InterpType.Bilinear);
                        }
                    }
                    Cms.Profile screen_profile;
                    if (FSpot.ColorManagement.Profiles.TryGetValue(Preferences.Get <string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
                    {
                        FSpot.ColorManagement.ApplyProfile(next, screen_profile);
                    }
                    loadRetries = 0;
                } catch (Exception) {
                    next = PixbufUtils.ErrorPixbuf;
                    if (++loadRetries < 10)
                    {
                        item.MoveNext(true);
                    }
                    else
                    {
                        loadRetries = 0;
                    }
                }
            }
        }
Пример #23
0
        public bool Convert(FilterRequest req)
        {
            string source   = req.Current.LocalPath;
            var    dest_uri = req.TempUri(System.IO.Path.GetExtension(source));

            using (var img = ImageFile.Create(req.Current)) {
                using (Pixbuf pixbuf = img.Load()) {
                    if (pixbuf.Width < size && pixbuf.Height < size)
                    {
                        return(false);
                    }
                }

                using (Pixbuf pixbuf = img.Load((int)size, (int)size)) {
                    PixbufUtils.CreateDerivedVersion(req.Current, dest_uri, 95, pixbuf);
                }
            }

            req.Current = dest_uri;
            return(true);
        }
Пример #24
0
        public bool Convert(FilterRequest req)
        {
            Uri source = req.Current;

            using (ImageFile img = ImageFile.Create(source)) {
                Pixbuf  pixbuf  = img.Load();
                Profile profile = img.GetProfile();

                Adjustment adjustment = CreateAdjustment(pixbuf, profile);
                Gdk.Pixbuf final      = adjustment.Adjust();

                Uri dest_uri = req.TempUri(Path.GetExtension(source.LocalPath));
                using (Stream output = File.OpenWrite(dest_uri.LocalPath)) {
                    img.Save(final, output);
                }
                final.Dispose();
                req.Current = dest_uri;

                return(true);
            }
        }
Пример #25
0
    public uint SaveVersion(Gdk.Pixbuf buffer, bool create_version)
    {
        uint version = DefaultVersionId;

        using (ImageFile img = ImageFile.Create(DefaultVersionUri)) {
            // Always create a version if the source is not a jpeg for now.
            create_version = create_version || !(img is FSpot.JpegFile);

            if (buffer == null)
            {
                throw new ApplicationException("invalid (null) image");
            }

            if (create_version)
            {
                version = CreateDefaultModifiedVersion(DefaultVersionId, false);
            }

            try {
                string version_path = GetVersionPath(version);

                using (Stream stream = File.OpenWrite(version_path)) {
                    img.Save(buffer, stream);
                }
                FSpot.ThumbnailGenerator.Create(version_path).Dispose();
                DefaultVersionId = version;
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                if (create_version)
                {
                    DeleteVersion(version);
                }

                throw e;
            }
        }

        return(version);
    }
Пример #26
0
 void CreateTagIconFromExternalPhoto()
 {
     try {
         using (var img = ImageFile.Create(new SafeUri(external_photo_chooser.Uri, true))) {
             using (Gdk.Pixbuf external_image = img.Load()) {
                 PreviewPixbuf = PixbufUtils.TagIconFromPixbuf(external_image);
             }
         }
     } catch (Exception) {
         string caption = Catalog.GetString("Unable to load image");
         string message = String.Format(Catalog.GetString("Unable to load \"{0}\" as icon for the tag"),
                                        external_photo_chooser.Uri);
         HigMessageDialog md = new HigMessageDialog(this,
                                                    DialogFlags.DestroyWithParent,
                                                    MessageType.Error,
                                                    ButtonsType.Close,
                                                    caption,
                                                    message);
         md.Run();
         md.Destroy();
     }
 }
Пример #27
0
    internal Result <ICameraFile> Create(
        CameraFilePath filePath,
        IEnumerable <ITag> metadata)
    {
        switch (filePath.GetExtension().ToLowerInvariant())
        {
        case ".jpg":
        case ".jpeg":
        case ".cr2":
            return(ImageFile.Create(filePath, metadata));

        case ".dng":
            return(DngImageFile.Create(filePath, metadata));

        case ".mp4":
        case ".mov":
            return(VideoFile.Create(filePath, metadata));

        default:
            throw new InvalidPathException($"Unknown file type {filePath}");
        }
    }
Пример #28
0
        public void Load(SafeUri uri)
        {
            if (is_disposed)
            {
                return;
            }

            //First, send a thumbnail if we have one
            if ((thumb = App.Instance.Container.Resolve <IThumbnailService> ().TryLoadThumbnail(uri, ThumbnailSize.Large)) != null)
            {
                pixbuf_orientation = ImageOrientation.TopLeft;
                EventHandler <AreaPreparedEventArgs> prep = AreaPrepared;
                if (prep != null)
                {
                    prep(this, new AreaPreparedEventArgs(true));
                }
                EventHandler <AreaUpdatedEventArgs> upd = AreaUpdated;
                if (upd != null)
                {
                    upd(this, new AreaUpdatedEventArgs(new Rectangle(0, 0, thumb.Width, thumb.Height)));
                }
            }

            using (var image_file = ImageFile.Create(uri)) {
                image_stream       = image_file.PixbufStream();
                pixbuf_orientation = image_file.Orientation;
            }

            loading = true;
            // The ThreadPool.QueueUserWorkItem hack is there cause, as the bytes to read are present in the stream,
            // the Read is CompletedAsynchronously, blocking the mainloop
            image_stream.BeginRead(buffer, 0, count, delegate(IAsyncResult r) {
                ThreadPool.QueueUserWorkItem(delegate {
                    HandleReadDone(r);
                });
            }, null);
        }
Пример #29
0
        public bool Convert(FilterRequest req)
        {
            Uri dest_uri = req.TempUri(System.IO.Path.GetExtension(req.Current.LocalPath));

            using (ImageFile img = ImageFile.Create(req.Current)) {
                using (Pixbuf in_pixbuf = img.Load()) {
                    using (Pixbuf out_pixbuf = PixbufUtils.UnsharpMask(in_pixbuf, radius, amount, threshold)) {
                        string destination_extension = Path.GetExtension(dest_uri.LocalPath);

                        if (Path.GetExtension(req.Current.LocalPath).ToLower() == Path.GetExtension(dest_uri.LocalPath).ToLower())
                        {
                            using (Stream output = File.OpenWrite(dest_uri.LocalPath)) {
                                img.Save(out_pixbuf, output);
                            }
                        }
                        else if (destination_extension == ".jpg")
                        {
                            // FIXME this is a bit of a nasty hack to work around
                            // the lack of being able to change the path in this filter
                            // and the lack of proper metadata copying yuck
                            Exif.ExifData exif_data;

                            exif_data = new Exif.ExifData(req.Current.LocalPath);

                            PixbufUtils.SaveJpeg(out_pixbuf, dest_uri.LocalPath, 90, exif_data);
                        }
                        else
                        {
                            throw new NotImplementedException(String.Format(Catalog.GetString("No way to save files of type \"{0}\""), destination_extension));
                        }
                    }
                }
            }

            req.Current = dest_uri;
            return(true);
        }
            public void Linearize(string name)
            {
                GammaTable table = new GammaTable(new ushort [] { 0x0000, 0x0000, 0x0000, 0x0000 });
                Profile    link  = new Profile(IccColorSpace.Rgb, new GammaTable [] { table, table, table });

                string path = CreateFile(name, 32);

                using (FilterRequest req = new FilterRequest(path)) {
                    ColorFilter filter = new ColorFilter();
                    filter.DeviceLink = link;
                    Assert.IsTrue(filter.Convert(req), "Filter failed to operate");
                    req.Preserve(req.Current);
                    Assert.IsTrue(System.IO.File.Exists(req.Current.LocalPath),
                                  "Error: Did not create " + req.Current);
                    Assert.IsTrue(new FileInfo(req.Current.LocalPath).Length > 0,
                                  "Error: " + req.Current + "is Zero length");
                    using (ImageFile img = ImageFile.Create(req.Current)) {
                        Pixbuf pixbuf = img.Load();
                        Assert.IsNotNull(pixbuf);
                        // We linearized to all black so this should pass the gray test
                        Assert.IsTrue(PixbufUtils.IsGray(pixbuf, 1), "failed to linearize" + req.Current);
                    }
                }
            }