コード例 #1
0
            public void TestSave()
            {
                string            desc   = "this is an example description";
                string            desc2  = "\x00a9 Novell Inc.";
                PixbufOrientation orient = PixbufOrientation.TopRight;

                Gdk.Pixbuf test = new Gdk.Pixbuf(null, "f-spot-32.png");
                string     path = ImageFile.TempPath("joe.jpg");

                PixbufUtils.SaveJpeg(test, path, 75, new Exif.ExifData());
                JpegFile jimg = new JpegFile(path);

                jimg.SetDescription(desc);
                jimg.SetOrientation(orient);
                jimg.SaveMetaData(path);
                JpegFile mod = new JpegFile(path);

                Assert.AreEqual(mod.Orientation, orient);
                Assert.AreEqual(mod.Description, desc);
                jimg.SetDescription(desc2);
                jimg.SaveMetaData(path);
                mod = new JpegFile(path);
                Assert.AreEqual(mod.Description, desc2);

                File.Delete(path);
            }
コード例 #2
0
        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);
        }
コード例 #3
0
        public string CreateFile()
        {
            Gdk.Pixbuf        test   = new Gdk.Pixbuf(null, "f-spot-32.png");
            string            path   = FSpot.ImageFile.TempPath("joe.jpg");
            string            desc   = "\x00a9 Novell Inc.";
            PixbufOrientation orient = PixbufOrientation.TopRight;

            PixbufUtils.SaveJpeg(test, path, quality, new Exif.ExifData());
            FSpot.JpegFile jimg = new FSpot.JpegFile(path);
            jimg.SetDescription(desc);
            jimg.SetOrientation(orient);
            jimg.SaveMetaData(path);

            return(path);
        }
コード例 #4
0
    public static void Resize(string orig_path, string dest_path, int size, bool copy_meta)
    {
        Exif.ExifData exif_data;
        if (copy_meta)
        {
            exif_data = new Exif.ExifData(orig_path);
        }
        else
        {
            exif_data = new Exif.ExifData();
        }

        Gdk.Pixbuf image = PixbufUtils.LoadAtMaxSize(orig_path, size, size);

        PixbufUtils.SaveJpeg(image, dest_path, 95, exif_data);
        image.Dispose();
    }
コード例 #5
0
        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);
        }
コード例 #6
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);
        }