public Photo Create(string newPath, string origPath, uint roll_id, out Pixbuf thumbnail) { Photo photo; using (FSpot.ImageFile img = FSpot.ImageFile.Create(origPath)) { long unix_time = DbUtils.UnixTimeFromDateTime(img.Date); string description = img.Description != null?img.Description.Split('\0') [0] : String.Empty; uint id = (uint)Database.Execute(new DbCommand("INSERT INTO photos (time, " + "directory_path, name, description, roll_id, default_version_id) " + "VALUES (:time, :directory_path, :name, :description, " + ":roll_id, :default_version_id)", "time", unix_time, "directory_path", System.IO.Path.GetDirectoryName(newPath), "name", System.IO.Path.GetFileName(newPath), "description", description, "roll_id", roll_id, "default_version_id", Photo.OriginalVersionId)); photo = new Photo(id, unix_time, newPath); AddToCache(photo); photo.Loaded = true; thumbnail = GenerateThumbnail(UriList.PathToFileUri(newPath), img); EmitAdded(photo); } return(photo); }
protected override void ProcessRequest(RequestItem request) { try { base.ProcessRequest(request); Gdk.Pixbuf image = request.result; if (image != null) { Uri uri; if (File.Exists(request.path)) { uri = UriList.PathToFileUri(request.path); } else { uri = new Uri(request.path); } Save(image, uri); } System.Threading.Thread.Sleep(75); } catch (System.Exception e) { System.Console.WriteLine(e.ToString()); } }
public static void DeleteThumbnail(string path) { string uri = UriList.PathToFileUri(path).ToString(); path = Thumbnail.PathForUri(uri, ThumbnailSize.Large); if (File.Exists(path)) { File.Delete(path); } }
private void HandleApply(object sender, EventArgs args) { BrowsablePointer item = view.Item; EditTarget target = new EditTarget(item); try { using (ImageFile img = ImageFile.Create(item.Current.DefaultVersionUri)) { Cairo.Format format = view.CompletePixbuf().HasAlpha ? Cairo.Format.Argb32 : Cairo.Format.Rgb24; MemorySurface dest = new MemorySurface(format, info.Bounds.Width, info.Bounds.Height); Context ctx = new Context(dest); effect.OnExpose(ctx, info.Bounds); ((IDisposable)ctx).Dispose(); string tmp = ImageFile.TempPath(item.Current.DefaultVersionUri.LocalPath); using (Gdk.Pixbuf output = Widgets.CairoUtils.CreatePixbuf(dest)) { using (System.IO.Stream stream = System.IO.File.OpenWrite(tmp)) { img.Save(output, stream); } } dest.Destroy(); // FIXME Not this again. I need to imlplement a real version of the transfer // function that shows progress in the main window and allows for all the // goodies we'll need. Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok; result = Gnome.Vfs.Xfer.XferUri(new Gnome.Vfs.Uri(UriList.PathToFileUri(tmp).ToString()), new Gnome.Vfs.Uri(target.Uri.ToString()), Gnome.Vfs.XferOptions.Default, Gnome.Vfs.XferErrorMode.Abort, Gnome.Vfs.XferOverwriteMode.Replace, delegate { System.Console.Write("."); return(1); }); target.Commit(); } } catch (System.Exception e) { System.Console.WriteLine(e); target.Delete(); Dialog d = new EditExceptionDialog((Gtk.Window)view.Toplevel, e, view.Item.Current); d.Show(); d.Run(); d.Destroy(); } Destroy(); }
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 bool Convert(FilterRequest request) { //FIXME: make it works for uri (and use it in CDExport) int i = 1; string path = destination.LocalPath; string filename = System.IO.Path.GetFileName(request.Source.LocalPath); string dest = System.IO.Path.Combine(path, filename); while (System.IO.File.Exists(dest)) { string numbered_name = String.Format("{0}-{1}{2}", System.IO.Path.GetFileNameWithoutExtension(filename), i++, System.IO.Path.GetExtension(filename)); dest = System.IO.Path.Combine(path, numbered_name); } System.IO.File.Copy(request.Current.LocalPath, dest); request.Current = UriList.PathToFileUri(dest); return(true); }
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 Uri TempUri(string extension) { string imgtemp; if (extension != null) { string temp = System.IO.Path.GetTempFileName(); imgtemp = temp + "." + extension; System.IO.File.Move(temp, imgtemp); } else { imgtemp = System.IO.Path.GetTempFileName(); } Uri uri = UriList.PathToFileUri(imgtemp); if (!temp_uris.Contains(uri)) { temp_uris.Add(uri); } return(uri); }
public static void MoveThumbnail(string old_path, string new_path) { File.Move(ThumbnailGenerator.ThumbnailPath(UriList.PathToFileUri(old_path)), ThumbnailGenerator.ThumbnailPath(UriList.PathToFileUri(new_path))); }
public System.Uri VersionUri(uint version_id) { return(UriList.PathToFileUri(GetVersionPath(version_id))); }
public FileBrowsableItem(string path) { this.uri = UriList.PathToFileUri(path); }
public static ImageFile Create(string path) { return(Create(UriList.PathToFileUri(path))); }
public static Gdk.Pixbuf Create(string path) { return(Create(UriList.PathToFileUri(path))); }
public UniqueNameFilter(string destination) : this(UriList.PathToFileUri(destination)) { }
public SingleView(string path) : this(UriList.PathToFileUri(path)) { }
public static string ThumbnailPath(string path) { return(ThumbnailPath(UriList.PathToFileUri(path))); }
public FilterRequest(string path) : this(UriList.PathToFileUri(path)) { }
public ImageFile(string path) { this.uri = UriList.PathToFileUri(path); }
static public Gdk.Pixbuf ValidateThumbnail(string photo_path, Gdk.Pixbuf pixbuf) { System.Uri uri = UriList.PathToFileUri(photo_path); return(ValidateThumbnail(uri, pixbuf)); }
public static bool HasLoader(string path) { return(HasLoader(UriList.PathToFileUri(path))); }