private void OnPhotoUploaded(IPhoto item) { Debug.Assert(null != item); if (!model.AttachTags && !model.RemoveTags) { return; } PhotoStore photo_store = FSpot.App.Instance.Database.Photos; FSpot.Photo photo = photo_store.GetByUri( item.DefaultVersion.Uri); Debug.Assert(null != photo); if (null == photo) { return; } if (model.AttachTags) { photo.AddTag(model.AttachedTags); } if (model.RemoveTags) { photo.RemoveTag(model.RemovedTags); } photo_store.Commit(photo); }
UpnpPhoto GetPhoto(FSpotPhoto photo, Container parent) { UpnpPhoto upnp_photo = null; if (!photos_cache.ContainsKey(photo.Id)) { var resource_options = new ResourceOptions { ProtocolInfo = new ProtocolInfo(Protocols.HttpGet, MimeTypeHelper.GetMimeType(photo.DefaultVersion.Uri)) }; var resource_uri = new Uri(string.Format("{0}object?id={1}", prefix, upnp_photo.Id)); var photo_options = new PhotoOptions { Title = photo.Name, Rating = photo.Rating.ToString(), Description = photo.Description, Resources = new [] { new Resource(resource_uri, resource_options) } }; upnp_photo = new UpnpPhoto((id++).ToString(), parent.Id, photo_options); photos_cache.Add(photo.Id, upnp_photo); } else { upnp_photo = photos_cache [photo.Id]; } return(upnp_photo); }
public static FaceImagePos[] DetectFace(Photo photo) { Uri uri = photo.DefaultVersionUri; string s = uri.LocalPath; //FIXME - not sure about this s.Replace("%20"," "); return DetectFace(new Emgu.CV.Image<Bgr, Byte>(s)); }
public static DetectionJob Create(Photo photo,JobPriority priority) { Log.Debug("DetectionJob .Create "+photo.Id); uint id = 0; DetectionJob job = new DetectionJob(id,photo.Id.ToString(), DateTime.Now, priority, persistent); Scheduler.Schedule(job,priority); job.Status = FSpot.Jobs.JobStatus.Scheduled; return job; }
protected void SendFile(FileInfo file, Photo photo, Stream dest) { stats.BytesSent += (int)file.Length; Log.Debug ("Sending {0}, {1} kb", file.FullName, file.Length / 1024); SendHeadersAndStartContent(dest, "Content-Type: " + MimeTypeForExt (file.Extension), "Content-Length: " + file.Length, "Last-Modified: " + photo.Time.ToString ("r")); using (Stream src = file.OpenRead ()) { byte[] buf = new byte[10240]; int read; while((read = src.Read(buf, 0, buf.Length)) != 0) { dest.Write (buf, 0, read); } } }
public static void SetPhotosData(this SelectionData selection_data, Photo [] photos, Atom target) { byte [] data = new byte [photos.Length * sizeof (uint)]; int i = 0; foreach (Photo photo in photos) { byte [] bytes = System.BitConverter.GetBytes (photo.Id); foreach (byte b in bytes) { data[i] = b; i++; } } selection_data.Set (target, 8, data, data.Length); }
public static Photo[] GetPhotosData(this SelectionData selection_data) { int size = sizeof (uint); int length = selection_data.Length / size; PhotoStore photo_store = App.Instance.Database.Photos; Photo [] photos = new Photo [length]; for (int i = 0; i < length; i ++) { uint id = System.BitConverter.ToUInt32 (selection_data.Data, i * size); photos[i] = photo_store.Get (id); } return photos; }
public Face(uint id,uint leftX,uint topY,uint width,Photo photo, Tag tag,bool tagConfirmed, bool autoDetected, bool autoRecognized, Pixbuf icon,long unix_time) : base(id) { this.leftX = leftX; this.topY = topY; this.width = width; this.photo = photo; this.tag = tag; this.tagConfirmed = tagConfirmed; this.autoDetected = autoDetected; this.autoRecognized = autoRecognized; this.iconPixbuf = icon; this.unix_time = unix_time; //FIXME Possible Error HERE photo_md5 = photo.MD5Sum; }
protected virtual void SendImage (Photo photo, Stream stream) { string path = photo.DefaultVersion.Uri.LocalPath; FileInfo file_info = new FileInfo(path); if (!file_info.Exists) { SendError (stream, "404 The file is not on the disk"); return; } FilterSet filters = new FilterSet (); filters.Add (new JpegFilter ()); filters.Add (new ResizeFilter (1600)); using (FilterRequest request = new FilterRequest (photo.DefaultVersion.Uri)) { filters.Convert (request); file_info = new FileInfo (request.Current.LocalPath); SendFile (file_info, photo, stream); } if (stats != null) stats.PhotoViews++; }
protected void DevelopPhoto(Photo p) { LoadPreference (UFRAW_JPEG_QUALITY_KEY); LoadPreference (UFRAW_ARGUMENTS_KEY); LoadPreference (UFRAW_BATCH_ARGUMENTS_KEY); PhotoVersion raw = p.GetVersion (Photo.OriginalVersionId) as PhotoVersion; if (!ImageFile.IsRaw (raw.Uri)) { Log.Warning ("The original version of this image is not a (supported) RAW file"); return; } string name = GetNextVersionFileName (p); System.Uri developed = GetUriForVersionFileName (p, name); string idfile = ""; if (ufraw_jpeg_quality < 1 || ufraw_jpeg_quality > 100) { Log.Debug ("Invalid JPEG quality specified, defaulting to quality 98"); ufraw_jpeg_quality = 98; } string args = ""; switch (executable) { case "ufraw": args += ufraw_args; if (GLib.FileFactory.NewForUri (Path.ChangeExtension (raw.Uri.ToString (), ".ufraw")).Exists) { // We found an ID file, use that instead of the raw file idfile = "--conf=" + GLib.Shell.Quote (Path.ChangeExtension (raw.Uri.LocalPath, ".ufraw")); } break; case "ufraw-batch": args += ufraw_batch_args; if (GLib.FileFactory.NewForUri (Path.Combine (FSpot.Core.Global.BaseDirectory, "batch.ufraw")).Exists) { // We found an ID file, use that instead of the raw file idfile = "--conf=" + GLib.Shell.Quote (Path.Combine (FSpot.Core.Global.BaseDirectory, "batch.ufraw")); } break; } args += String.Format(" --exif --overwrite --create-id=also --compression={0} --out-type=jpeg {1} --output={2} {3}", ufraw_jpeg_quality, idfile, GLib.Shell.Quote (developed.LocalPath), GLib.Shell.Quote (raw.Uri.LocalPath)); Log.Debug (executable + " " + args); System.Diagnostics.Process ufraw = System.Diagnostics.Process.Start (executable, args); ufraw.WaitForExit (); if (!(GLib.FileFactory.NewForUri (developed.ToString ())).Exists) { Log.Warning ("UFRaw quit with an error. Check that you have UFRaw 0.13 or newer. Or did you simply clicked on Cancel?"); return; } if (GLib.FileFactory.NewForUri (Path.ChangeExtension (developed.ToString (), ".ufraw")).Exists) { // We save our own copy of the last ufraw settings, as ufraw can overwrite it's own last used settings outside f-spot File.Delete (Path.Combine (FSpot.Core.Global.BaseDirectory, "batch.ufraw")); File.Copy (Path.ChangeExtension (developed.LocalPath, ".ufraw"), Path.Combine (FSpot.Core.Global.BaseDirectory, "batch.ufraw")); // Rename the ufraw file to match the original RAW filename, instead of the (Developed In UFRaw) filename if (!(Path.ChangeExtension (raw.Uri.LocalPath, ".ufraw") == Path.ChangeExtension (developed.LocalPath, ".ufraw"))){ File.Delete (Path.ChangeExtension (raw.Uri.LocalPath, ".ufraw")); File.Move (Path.ChangeExtension (developed.LocalPath, ".ufraw"), Path.ChangeExtension (raw.Uri.LocalPath, ".ufraw")); } } p.DefaultVersionId = p.AddVersion (new SafeUri (developed).GetBaseUri (),new SafeUri (developed).GetFilename (), name, true); p.Changes.DataChanged = true; App.Instance.Database.Photos.Commit (p); }
private static System.Uri GetUriForVersionFileName(Photo p, string version_name) { return new System.Uri (System.IO.Path.Combine (DirectoryPath (p), version_name )); }
public void UpdateThisUri(int index, string path, ref Photo photo) { if (photo == null) photo = photo_store.Get (photo_id_array[index]); PhotoVersion version = photo.GetVersion ( (uint) version_id_array[index]) as PhotoVersion; version.BaseUri = new SafeUri ( path ).GetBaseUri (); version.Filename = new SafeUri ( path ).GetFilename (); photo.Changes.UriChanged = true; photo.Changes.ChangeVersion ( (uint) version_id_array[index] ); }
protected override void SendImage(Photo photo, Stream dest) { Gdk.Pixbuf thumb = FSpot.Platform.ThumbnailFactory.LoadThumbnail (photo.DefaultVersionUri); byte[] buf = thumb.SaveToBuffer ("png"); SendHeadersAndStartContent(dest, "Content-Type: " + MimeTypeForExt (".png"), "Content-Length: " + buf.Length, "Last-Modified: " + photo.Time.ToString ("r")); dest.Write (buf, 0, buf.Length); }
private string PreparePhoto(string template, Photo photo) { string photo_s = template.Replace ("PHOTO_ID", photo.Id.ToString ()) .Replace ("PHOTO_NAME", Escape (photo.Name)) .Replace ("PHOTO_DESCRIPTION", Escape (photo.Description)) .Replace ("VERSION_NAME", Escape (photo.DefaultVersion.Name)); string tags = TagsToString(photo); photo_s = photo_s.Replace ("PHOTO_TAGS", Escape (tags)); return photo_s; }
void ImportPhoto (Photo photo, bool copy) { Log.WarningFormat ("Importing {0}", photo.Name); PhotoStore from_store = from_db.Photos; PhotoStore to_store = to_db.Photos; string photo_path = photo.VersionUri (Photo.OriginalVersionId).AbsolutePath; while (!System.IO.File.Exists (photo_path)) { Log.Debug ("Not found, trying the mappings..."); foreach (string key in PathMap.Keys) { string path = photo_path; path = path.Replace (key, PathMap [key]); Log.DebugFormat ("Replaced path {0}", path); if (System.IO.File.Exists (path)) { photo_path = path; break;; } } if (System.IO.File.Exists (photo_path)) { Log.Debug ("Exists!!!"); continue; } string [] parts = photo_path.Split (new char[] {'/'}); if (parts.Length > 6) { string folder = String.Join ("/", parts, 0, parts.Length - 4); PickFolderDialog pfd = new PickFolderDialog (mdd.Dialog, folder); string new_folder = pfd.Run (); pfd.Dialog.Destroy (); if (new_folder == null) //Skip return; Log.DebugFormat ("{0} maps to {1}", folder, new_folder); PathMap[folder] = new_folder; } else Console.WriteLine ("point me to the file"); Console.WriteLine ("FNF: {0}", photo_path); } string destination; Gdk.Pixbuf pixbuf; Photo newp; if (copy) destination = FileImportBackend.ChooseLocation (photo_path, null); else destination = photo_path; // Don't copy if we are already home if (photo_path == destination) newp = to_store.Create (destination, roll_map [photo.RollId], out pixbuf); else { System.IO.File.Copy (photo_path, destination); newp = to_store.Create (destination, photo_path, roll_map [photo.RollId], out pixbuf); try { File.SetAttributes (destination, File.GetAttributes (destination) & ~FileAttributes.ReadOnly); DateTime create = File.GetCreationTime (photo_path); File.SetCreationTime (destination, create); DateTime mod = File.GetLastWriteTime (photo_path); File.SetLastWriteTime (destination, mod); } catch (IOException) { // we don't want an exception here to be fatal. } } if (newp == null) return; foreach (Tag t in photo.Tags) { Log.WarningFormat ("Tagging with {0}", t.Name); newp.AddTag (tag_map [t.Id]); } foreach (uint version_id in photo.VersionIds) if (version_id != Photo.OriginalVersionId) { PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion; uint newv = newp.AddVersion (version.Uri, version.Name, version.IsProtected); if (version_id == photo.DefaultVersionId) newp.DefaultVersionId = newv; } //FIXME Import extra info (time, description, rating) newp.Time = photo.Time; newp.Description = photo.Description; newp.Rating = photo.Rating; to_store.Commit (newp); }
private static string GetVersionName(Photo p, int i) { string name = Catalog.GetPluralString ("PhotoMosaic", "PhotoMosaic ({0})", i); name = String.Format (name, i); if (p.VersionNameExists (name)) return GetVersionName (p, i + 1); return name; }
protected void LoadPhoto (Photo photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile) { // FIXME: We might get this value from the PhotoImageView. using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) { photo_pixbuf = img.Load (); photo_profile = img.GetProfile (); } }
private void ShowError (System.Exception e, Photo photo) { string msg = Catalog.GetString ("Error editing photo"); string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"), e.Message, photo.Name); HigMessageDialog md = new HigMessageDialog ((Gtk.Window)this.Toplevel, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); }
private static bool SamePlaceAndName(Photo p1, Photo p2) { return DirectoryPath (p1) == DirectoryPath (p2) && System.IO.Path.GetFileNameWithoutExtension (p1.Name) == System.IO.Path.GetFileNameWithoutExtension (p2.Name); }
public MergeRequest(Photo raw, Photo jpeg) { this.raw = raw; this.jpeg = jpeg; }
public EditTarget (BrowsablePointer item) { this.item = item; photo = item.Current as Photo; if (photo != null) { version = photo.DefaultVersionId; bool create = version == Photo.OriginalVersionId; if (create) { version = photo.CreateDefaultModifiedVersion (photo.DefaultVersionId, false); created_version = true; } } }
UpnpPhoto GetPhoto (FSpotPhoto photo, Container parent) { UpnpPhoto upnp_photo = null; if (!photos_cache.ContainsKey (photo.Id)) { var resource_options = new ResourceOptions { ProtocolInfo = new ProtocolInfo (Protocols.HttpGet, MimeTypeHelper.GetMimeType(photo.DefaultVersion.Uri)) }; var resource_uri = new Uri (string.Format ("{0}object?id={1}", prefix, upnp_photo.Id)); var photo_options = new PhotoOptions { Title = photo.Name, Rating = photo.Rating.ToString(), Description = photo.Description, Resources = new [] { new Resource (resource_uri, resource_options) } }; upnp_photo = new UpnpPhoto ((id++).ToString (), parent.Id, photo_options); photos_cache.Add (photo.Id, upnp_photo); } else { upnp_photo = photos_cache [photo.Id]; } return upnp_photo; }
private void SearchVersionUriToChange(Photo photo, string old_base, string new_base) { foreach (uint version_id in photo.VersionIds) { PhotoVersion version = photo.GetVersion (version_id) as PhotoVersion; if ( ChangeThisVersionUri (version, old_base, new_base) ) AddVersionToArrays ( photo.Id, version_id, version.Uri.AbsolutePath, CreateNewPath (old_base, new_base, version)); // else // System.Console.WriteLine ("L : {0}", version.Uri.AbsolutePath); } }
private static string DirectoryPath(Photo p) { System.Uri uri = p.VersionUri (Photo.OriginalVersionId); return uri.Scheme + "://" + uri.Host + System.IO.Path.GetDirectoryName (uri.AbsolutePath); }
private static string GetVersionName(Photo p) { return GetVersionName (p, 1); }
public void CopyAttributesFrom(Photo that) { Time = that.Time; Description = that.Description; Rating = that.Rating; AddTag (that.Tags); }
private System.Uri GetUriForVersionName(Photo p, string version_name) { string name_without_ext = System.IO.Path.GetFileNameWithoutExtension (p.Name); return new System.Uri (System.IO.Path.Combine (DirectoryPath (p), name_without_ext + " (" + version_name + ")" + ".jpg")); }
private static string DirectoryPath(Photo p) { return p.VersionUri (Photo.OriginalVersionId).GetBaseUri (); }
public void Save() { if (!Changed) { this.Dialog.Destroy(); return; } if (!view.Item.IsValid) { return; } Console.WriteLine("Saving...."); Photo photo = (Photo)view.Item.Current; try { bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId; Gdk.Pixbuf orig = view.CompletePixbuf(); Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, orig.Width, orig.Height); Cms.Profile abs = AdjustmentProfile(); // FIXME this shouldn't use the screen as the destination profile. Cms.Profile destination = Cms.Profile.GetScreenProfile(view.Screen); if (destination == null) { destination = Cms.Profile.CreateStandardRgb(); } Cms.Profile [] list = new Cms.Profile [] { image_profile, abs, destination }; Cms.Transform transform = new Cms.Transform(list, PixbufUtils.PixbufCmsFormat(orig), PixbufUtils.PixbufCmsFormat(final), Cms.Intent.Perceptual, 0x0000); PixbufUtils.ColorAdjust(orig, final, transform); photo.SaveVersion(final, create_version); ((PhotoQuery)view.Query).Commit(view.Item.Index); final.Dispose(); } catch (System.Exception e) { string msg = Catalog.GetString("Error saving adjusted photo"); string desc = String.Format(Catalog.GetString("Received exception \"{0}\". Unable to save photo {1}"), e.Message, photo.Name); HigMessageDialog md = new HigMessageDialog((Gtk.Window)Dialog.Toplevel, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run(); md.Destroy(); } this.Dialog.Sensitive = false; this.Dialog.Destroy(); }
private static string GetNextVersionFileName(Photo p) { return GetNextVersionFileName (p, 0); }
protected string TagsToString(Photo photo) { string tags = ""; foreach (Tag tag in photo.Tags) { tags += ", " + tag.Name; } return tags.Length > 1 ? tags.Substring (2) : tags; }
private static string GetNextVersionFileName(Photo p, int i) { Regex exiflowpat = new Regex(@"^(\d{8}(-\d{6})?-.{3}\d{4}-.{2})(\d)(.{2})\.([^.]*$)"); Match exiflowpatmatch = exiflowpat.Match(p.Name); string filename = String.Format("{0}{1}00.jpg", exiflowpatmatch.Groups[1], i, exiflowpatmatch.Groups[5]); System.Uri developed = GetUriForVersionFileName (p, filename); if (p.VersionNameExists (GetVersionName(filename)) || System.IO.File.Exists(GLib.Shell.Quote(developed.LocalPath))) return GetNextVersionFileName (p, i + 1); return filename; }
public int CompareTo(Photo photo) { int result = Id.CompareTo (photo.Id); if (result == 0) return 0; return this.Compare (photo); }
public SlideShow(string name) { Tag tag; if (name != null) { tag = Database.Tags.GetTagByName(name); } else { int id = Preferences.Get <int> (Preferences.SCREENSAVER_TAG); tag = Database.Tags.GetTagById(id); } Photo [] photos; if (tag != null) { photos = Database.Photos.Query(new Tag [] { tag }); } else if (Preferences.Get <int> (Preferences.SCREENSAVER_TAG) == 0) { photos = db.Photos.Query(new Tag [] {}); } else { photos = new Photo [0]; } window = new XScreenSaverSlide(); SetStyle(window); if (photos.Length > 0) { Array.Sort(photos, new Photo.RandomSort()); Gdk.Pixbuf black = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, 1, 1); black.Fill(0x00000000); slideview = new SlideView(black, photos); window.Add(slideview); } else { Gtk.HBox outer = new Gtk.HBox(); Gtk.HBox hbox = new Gtk.HBox(); Gtk.VBox vbox = new Gtk.VBox(); outer.PackStart(new Gtk.Label(String.Empty)); outer.PackStart(vbox, false, false, 0); vbox.PackStart(new Gtk.Label(String.Empty)); vbox.PackStart(hbox, false, false, 0); hbox.PackStart(new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog), false, false, 0); outer.PackStart(new Gtk.Label(String.Empty)); string msg; string long_msg; if (tag != null) { msg = String.Format(Catalog.GetString("No photos matching {0} found"), tag.Name); long_msg = String.Format(Catalog.GetString("The tag \"{0}\" is not applied to any photos. Try adding\n" + "the tag to some photos or selecting a different tag in the\n" + "F-Spot preference dialog."), tag.Name); } else { msg = Catalog.GetString("Search returned no results"); long_msg = Catalog.GetString("The tag F-Spot is looking for does not exist. Try\n" + "selecting a different tag in the F-Spot preference\n" + "dialog."); } Gtk.Label label = new Gtk.Label(msg); hbox.PackStart(label, false, false, 0); Gtk.Label long_label = new Gtk.Label(long_msg); long_label.Markup = String.Format("<small>{0}</small>", long_msg); vbox.PackStart(long_label, false, false, 0); vbox.PackStart(new Gtk.Label(String.Empty)); window.Add(outer); SetStyle(label); SetStyle(long_label); //SetStyle (image); } window.ShowAll(); }