コード例 #1
0
ファイル: Project.cs プロジェクト: ivynetca/lapsestudio
 protected virtual void LoadThumbnails(string[] files)
 {
     Exiftool.ExtractThumbnails(files);
 }
コード例 #2
0
ファイル: XMP.cs プロジェクト: ivynetca/lapsestudio
 /// <summary>
 /// Write all values to disk
 /// </summary>
 public void Write()
 {
     Exiftool.WriteXMPMetadata(Path, this);
 }
コード例 #3
0
ファイル: Project.cs プロジェクト: ivynetca/lapsestudio
        protected void LoadMetadata(string directory)
        {
            string[]    lines   = Exiftool.GetExifMetadata(directory);
            CultureInfo culture = new CultureInfo("en-US");

            if (lines != null)
            {
                string TVtmp;
                string AVtmp;
                string SVtmp;
                double TVdenom;
                double TVnume;
                double tmpD;
                int    tmpI;
                int    f = -1;

                for (int i = 0; i < lines.Length; i++)
                {
                    if (MainWorker.CancellationPending)
                    {
                        return;
                    }


                    if (lines[i].StartsWith("======== "))
                    {
                        f = Frames.FindIndex(t => lines[i].ToLower() == "======== " + t.FilePath.ToLower().Replace(@"\", "/"));
                    }
                    else if (f >= 0)
                    {
                        if (lines[i].ToLower().StartsWith("aperturevalue"))
                        {
                            AVtmp = lines[i].Substring(lines[i].IndexOf(":") + 2);
                            if (double.TryParse(AVtmp, NumberStyles.Any, culture, out tmpD))
                            {
                                Frames[f].AVstring = AVtmp;
                                Frames[f].Av       = tmpD;
                                Frames[f].Av       = Math.Log(Math.Pow(Frames[f].Av, 2), 2);
                            }
                            else
                            {
                                Frames[f].Av       = 0;
                                Frames[f].AVstring = "N/A";
                            }
                        }
                        else if (lines[i].ToLower().StartsWith("shutterspeedvalue"))
                        {
                            TVtmp = lines[i].Substring(lines[i].IndexOf(":") + 2);

                            if (TVtmp.Contains(@"/"))
                            {
                                if (double.TryParse(TVtmp.Substring(0, TVtmp.IndexOf(@"/")), NumberStyles.Any, culture, out TVnume) &&
                                    double.TryParse(TVtmp.Substring(TVtmp.IndexOf(@"/") + 1), NumberStyles.Any, culture, out TVdenom))
                                {
                                    Frames[f].Tv       = TVnume / TVdenom;
                                    Frames[f].TVstring = TVtmp;
                                }
                                else
                                {
                                    Frames[f].TVstring = "N/A";
                                }
                            }
                            else if (double.TryParse(TVtmp, NumberStyles.Any, culture, out tmpD))
                            {
                                Frames[f].Tv       = tmpD;
                                Frames[f].TVstring = TVtmp;
                            }
                            else
                            {
                                Frames[f].TVstring = "N/A";
                            }

                            Frames[f].Tv = Math.Log(1 / Frames[f].Tv, 2);
                        }
                        else if (lines[i].ToLower().StartsWith("iso"))
                        {
                            SVtmp = lines[i].Substring(lines[i].IndexOf(":") + 2);
                            if (int.TryParse(SVtmp, out tmpI))
                            {
                                Frames[f].Sv       = Math.Log(tmpI, 3.125f);
                                Frames[f].SVstring = SVtmp;
                            }
                            else
                            {
                                Frames[f].SVstring = "N/A";
                            }
                        }
                        else if (lines[i].ToLower().StartsWith("wb_rggblevelsasshot"))
                        {
                            //string[] WBtmp = lines[i].Substring(lines[i].IndexOf(":") + 2).Split(' ');
                            //int[] WBvals = new int[4] { Convert.ToInt32(WBtmp[0]), Convert.ToInt32(WBtmp[1]), Convert.ToInt32(WBtmp[2]), Convert.ToInt32(WBtmp[3]) };
                            //LTODO: calc the resulting brightness steps and write to Frames[f].WB
                        }
                        else if (lines[i].ToLower().StartsWith("colorspace"))
                        {
                            string colspace = lines[i].Substring(lines[i].IndexOf(":") + 2).ToLower().Replace(" ", "");
                            switch (colspace)
                            {
                            case "adobergb":
                                Frames[f].ColorSpace = new RGBColorspaceAdobeRGB();
                                break;

                            case "widegamut":
                            case "widegamutrgb":
                            case "adobewidegamut":
                            case "adobewidegamutrgb":
                                Frames[f].ColorSpace = new RGBColorspaceWideGamutRGB();
                                break;

                            case "ciergb":
                                Frames[f].ColorSpace = new RGBColorspaceCIERGB();
                                break;

                            case "prophotorgb":
                            case "prophoto":
                                Frames[f].ColorSpace = new RGBColorspaceProPhotoRGB();
                                break;

                            case "srgb":
                            default:
                                Frames[f].ColorSpace = new RGBColorspacesRGB();
                                break;
                            }
                        }
                        else if (lines[i].ToLower().StartsWith("imagesize"))
                        {
                            string[] tmp = lines[i].Substring(lines[i].IndexOf(":") + 2).Split('x');
                            if (int.TryParse(tmp[0], out tmpI))
                            {
                                Frames[f].Width = tmpI;
                            }
                            else
                            {
                                Frames[f].Width = 1;
                            }
                            if (int.TryParse(tmp[1], out tmpI))
                            {
                                Frames[f].Height = tmpI;
                            }
                            else
                            {
                                Frames[f].Height = 1;
                            }
                        }
                    }

                    if (f >= 0 && f < Frames.Count)
                    {
                        if (Frames[f].AVstring == "N/A" && Frames[f].TVstring == "N/A" && Frames[f].SVstring == "N/A")
                        {
                            Frames[f].HasMetadata = false;
                        }
                        else
                        {
                            Frames[f].HasMetadata = true;
                        }

                        //Brightness Value
                        Frames[f].Bv = Frames[f].Av + Frames[f].Tv - Frames[f].Sv;
                    }
                }
            }
        }
コード例 #4
0
ファイル: XMP.cs プロジェクト: ivynetca/lapsestudio
        internal void Read()
        {
            string[] lines = Exiftool.GetXMPMetadata(Path);
            if (lines == null)
            {
                return;
            }
            Values.Clear();
            CultureInfo culture = new CultureInfo("en-US");

            for (int i = 0; i < lines.Length; i++)
            {
                lines[i] = lines[i].Trim();
                string name  = lines[i].Substring(0, lines[i].IndexOf(':')).Trim();
                string value = lines[i].Substring(lines[i].IndexOf(':') + 1).Replace("\"", "").Trim();

                if (name == "RawFileName")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "Version")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToDouble(value, culture), typeof(double), false, 7.4, 7.4));
                }
                else if (name == "ProcessVersion")
                {
                    FileVersion = value;
                }
                else if (name == "WhiteBalance")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "Temperature")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 2000, 50000));
                }
                else if (name == "Tint")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -150, 150));
                }
                else if (name == "Saturation")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "Sharpness")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 150));
                }
                else if (name == "LuminanceSmoothing")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "ColorNoiseReduction")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "VignetteAmount")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "ShadowTint")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "RedHue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "RedSaturation")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "GreenHue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "GreenSaturation")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "BlueHue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "BlueSaturation")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "Vibrance")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentRed")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentOrange")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentYellow")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentGreen")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentAqua")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentBlue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentPurple")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "HueAdjustmentMagenta")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentRed")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentOrange")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentYellow")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentGreen")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentAqua")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentBlue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentPurple")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SaturationAdjustmentMagenta")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentRed")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentOrange")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentYellow")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentGreen")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentAqua")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentBlue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentPurple")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LuminanceAdjustmentMagenta")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "GrayMixerRed")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -100, 100));
                }
                else if (name == "GrayMixerOrange")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, 0, 360));
                }
                else if (name == "GrayMixerYellow")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, 0, 100));
                }
                else if (name == "GrayMixerGreen")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, 0, 360));
                }
                else if (name == "GrayMixerAqua")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, 0, 100));
                }
                else if (name == "GrayMixerBlue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -100, 100));
                }
                else if (name == "GrayMixerPurple")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, 0, 0));
                }
                else if (name == "GrayMixerMagenta")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, 0, 0));
                }
                else if (name == "SplitToningShadowHue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 0));
                }
                else if (name == "SplitToningShadowSaturation")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 0));
                }
                else if (name == "SplitToningHighlightHue")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 25, 25));
                }
                else if (name == "SplitToningHighlightSaturation")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 50, 50));
                }
                else if (name == "SplitToningBalance")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 75, 75));
                }
                else if (name == "ParametricShadows")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "ParametricDarks")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "ParametricLights")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "ParametricHighlights")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "ParametricShadowSplit")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "ParametricMidtoneSplit")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "ParametricHighlightSplit")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "SharpenRadius")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToDouble(value, culture), typeof(double), true, 1, 1));
                }
                else if (name == "SharpenDetail")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "SharpenEdgeMasking")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "PostCropVignetteAmount")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 1, 100));
                }
                else if (name == "GrainAmount")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "ColorNoiseReductionDetail")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LensProfileEnable")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "LensManualDistortionAmount")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "PerspectiveVertical")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 50, 100));
                }
                else if (name == "PerspectiveHorizontal")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "PerspectiveRotate")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToDouble(value, culture), typeof(double), false, -5, 100));
                }
                else if (name == "PerspectiveScale")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "AutoLateralCA")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 150));
                }
                else if (name == "Exposure2012")
                {
                    Exposure = Convert.ToDouble(value, culture);
                }
                else if (name == "Contrast2012")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "Highlights2012")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "Shadows2012")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, -100, 100));
                }
                else if (name == "Whites2012")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "Blacks2012")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "Clarity2012")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 10, 100));
                }
                else if (name == "DefringePurpleAmount")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "DefringePurpleHueLo")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 20));
                }
                else if (name == "DefringePurpleHueHi")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 10, 90));
                }
                else if (name == "DefringeGreenAmount")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "DefringeGreenHueLo")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "DefringeGreenHueHi")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "ConvertToGrayscale")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToBoolean(value), typeof(bool), false, false, true));
                }
                else if (name == "ToneCurveName2012")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "CameraProfile")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "CameraProfileDigest")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "LensProfileSetup")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "LensProfileName")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "LensProfileFilename")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), true, String.Empty, String.Empty));
                }
                else if (name == "LensProfileDigest")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "LensProfileDistortionScale")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "LensProfileChromaticAberrationScale")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "LensProfileVignettingScale")
                {
                    Values.Add(name, new XMPentry(name, value, typeof(string), false, String.Empty, String.Empty));
                }
                else if (name == "AlreadyApplied")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToBoolean(value), typeof(bool), false, false, true));
                }
                else if (name == "Shadows")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), false, 0, 100));
                }
                else if (name == "Brightness")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -150, 150));
                }
                else if (name == "Contrast")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -50, 100));
                }
                else if (name == "FillLight")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -100, 100));
                }
                else if (name == "HighlightRecovery")
                {
                    Values.Add(name, new XMPentry(name, Convert.ToInt32(value), typeof(int), true, -100, 100));
                }
            }

            NewExposure = Exposure;
        }