//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); }