public static CreateDerivedVersion ( |
||
source | ||
destination | ||
return | void |
public bool Convert(FilterRequest req) { var source = req.Current; req.Current = req.TempUri("jpg"); PixbufUtils.CreateDerivedVersion(source, req.Current, quality); return(true); }
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); }
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); }
//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); }