public void StringNames(string name) { string path = CreateFile(name, 1024); string thumb_path = ThumbnailGenerator.ThumbnailPath(path); ThumbnailGenerator.Create(path); Assert.IsTrue(File.Exists(thumb_path), String.Format("Missing: {0} created from {1}", thumb_path, path)); using (Gdk.Pixbuf thumb = new Gdk.Pixbuf(thumb_path)) { Assert.IsNotNull(thumb); Assert.AreEqual(thumb.GetOption(ThumbUri), UriList.PathToFileUriEscaped(path)); Assert.AreEqual(new Uri(thumb.GetOption(ThumbUri)), UriList.PathToFileUri(path)); Assert.IsTrue(ThumbnailGenerator.ThumbnailIsValid(thumb, UriList.PathToFileUri(path))); } File.Delete(path); File.Delete(thumb_path); }
public void BadNames(string name) { string path = CreateFile(name, 512); System.Uri uri = UriList.PathToFileUri(path); Gnome.ThumbnailFactory factory = new Gnome.ThumbnailFactory(Gnome.ThumbnailSize.Large); string escaped = UriList.PathToFileUriEscaped(path); string large_path = Gnome.Thumbnail.PathForUri(escaped, Gnome.ThumbnailSize.Large); using (Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(uri.LocalPath)) { factory.SaveThumbnail(pixbuf, escaped, System.DateTime.Now); Assert.IsTrue(File.Exists(large_path), String.Format("Missing: {0} created from {1} as {2}", large_path, path, escaped)); Gdk.Pixbuf thumb = new Gdk.Pixbuf(large_path); Assert.IsNotNull(thumb); } File.Delete(path); File.Delete(large_path); }
public void ProcessImage(int image_num, Filters.FilterSet filter_set) { IBrowsableItem photo = collection [image_num]; string photo_path = photo.DefaultVersionUri.LocalPath; string path; ScaleRequest req; req = requests [0]; MakeDir(SubdirPath(req.Name)); path = SubdirPath(req.Name, ImageName(image_num)); using (Filters.FilterRequest request = new Filters.FilterRequest(photo.DefaultVersionUri)) { filter_set.Convert(request); if (request.Current.LocalPath == path) { request.Preserve(request.Current); } else { File.Copy(request.Current.LocalPath, path, true); } if (photo != null && photo is Photo && Core.Database != null) { Core.Database.Exports.Create((photo as Photo).Id, (photo as Photo).DefaultVersionId, ExportStore.FolderExportType, // FIXME this is wrong, the final path is the one // after the Xfer. UriList.PathToFileUriEscaped(path).ToString()); } using (Exif.ExifData data = new Exif.ExifData(photo_path)) { for (int i = 1; i < requests.Length; i++) { req = requests [i]; if (scale && req.AvoidScale(size)) { continue; } Filters.FilterSet req_set = new Filters.FilterSet(); req_set.Add(new Filters.ResizeFilter((uint)Math.Max(req.Width, req.Height))); if ((bool)Preferences.Get(Preferences.EXPORT_FOLDER_SHARPEN)) { if (req.Name == "lq") { req_set.Add(new Filters.SharpFilter(0.1, 2, 4)); } if (req.Name == "thumbs") { req_set.Add(new Filters.SharpFilter(0.1, 2, 5)); } } using (Filters.FilterRequest tmp_req = new Filters.FilterRequest(photo.DefaultVersionUri)) { req_set.Convert(tmp_req); MakeDir(SubdirPath(req.Name)); path = SubdirPath(req.Name, ImageName(image_num)); System.IO.File.Copy(tmp_req.Current.LocalPath, path, true); } } } } }