CreateDerivedVersion() публичный статический Метод

public static CreateDerivedVersion ( SafeUri source, SafeUri destination ) : void
source Hyena.SafeUri
destination Hyena.SafeUri
Результат void
Пример #1
0
        public bool Convert(FilterRequest req)
        {
            var source = req.Current;

            req.Current = req.TempUri("jpg");

            PixbufUtils.CreateDerivedVersion(source, req.Current, quality);

            return(true);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        //FIXME: won't work on non file uris
        public uint SaveVersion(Gdk.Pixbuf buffer, bool create_version)
        {
            uint version = DefaultVersionId;

            using (var img = ImageFile.Create(DefaultVersion.Uri)) {
                // Always create a version if the source is not a jpeg for now.
                create_version = create_version || ImageFile.IsJpeg(DefaultVersion.Uri);

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

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

                try {
                    var versionUri = VersionUri(version);

                    PixbufUtils.CreateDerivedVersion(DefaultVersion.Uri, versionUri, 95, buffer);
                    GetVersion(version).ImportMD5 = HashUtils.GenerateMD5(VersionUri(version));
                    DefaultVersionId = version;
                } catch (System.Exception e) {
                    Log.Exception(e);
                    if (create_version)
                    {
                        DeleteVersion(version);
                    }

                    throw e;
                }
            }

            return(version);
        }