AddVersion() public method

public AddVersion ( SafeUri base_uri, string filename, string name ) : uint
base_uri Hyena.SafeUri
filename string
name string
return uint
Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
		void AddAndChangeToNewVersion(Photo p, System.Uri outputUri, string name) {
			p.DefaultVersionId = p.AddVersion (outputUri, name, true);
			p.Changes.DataChanged = true;
			MainWindow.Toplevel.Database.Photos.Commit (p);
		}