/// <summary>
        /// Given size units in normal pixels, translate them into device independent pixels (the out parameters)
        /// </summary>
        /// <param name="widthInPixels"></param>
        /// <param name="heightInPixels"></param>
        /// <param name="widthInDeviceIndependentPixels"></param>
        /// <param name="heightInDeviceIndependentPixels"></param>
        public static void TransformPixelsToDeviceIndependentPixels(int widthInPixels,
                                                                    int heightInPixels,
                                                                    out double widthInDeviceIndependentPixels,
                                                                    out double heightInDeviceIndependentPixels)
        {
            IntPtr hDc = GetDC(IntPtr.Zero);

            if (hDc != IntPtr.Zero)
            {
                int dpiX = GetDeviceCaps(hDc, LOGPIXELSX);
                int dpiY = GetDeviceCaps(hDc, LOGPIXELSY);

                _ = ReleaseDC(IntPtr.Zero, hDc);

                widthInDeviceIndependentPixels  = 96 * widthInPixels / (double)dpiX;
                heightInDeviceIndependentPixels = 96 * heightInPixels / (double)dpiY;
            }
            else
            {
                // This is very unlikely.
                // As a workaround, we just return the original pixel size. While this may not be the correct size (depending on the actual dpi),
                // it will not crash the program and at least maintains the correct aspect ration
                widthInDeviceIndependentPixels  = widthInPixels;
                heightInDeviceIndependentPixels = heightInPixels;
                TracePrint.PrintMessage("In TransformPixelsToDeviceIndependentPixels: Failed to get DC.");
            }
        }
        public static Dictionary <string, ImageMetadata> LoadMetadata(string filePath)
        {
            Dictionary <string, ImageMetadata> metadataDictionary = new Dictionary <string, ImageMetadata>();

            try
            {
                foreach (Directory metadataDirectory in ImageMetadataReader.ReadMetadata(filePath))
                {
                    // TraceDebug.PrintMessage(String.Format("metadataDirectory is: {0}", metadataDirectory.Name));
                    foreach (Tag metadataTag in metadataDirectory.Tags)
                    {
                        ImageMetadata metadata = new ImageMetadata(metadataTag.DirectoryName, metadataTag.Name, metadataTag.Description);

                        // Check if the metadata name is already in the dictionary.
                        // If so, just skip it as its not clear what else to do with it
                        // Note that Quicktime mp4s appear to have multiple directories called Quicktime Track Headers.
                        // Exiftool seems to handle this properly but MetadataDetector generates duplicates.
                        // So only the first Quicktime track header is added to the dictionary.
                        if (!metadataDictionary.ContainsKey(metadata.Key))
                        {
                            metadataDictionary.Add(metadata.Key, metadata);
                        }
                        else
                        {
                            TracePrint.PrintMessage(String.Format("ImageMetadata Dictionary: Duplicate metadata key: {0}:{1} (Note that Quicktime may have multiple Track Headers)", metadataDirectory.Name, metadata.Key));
                        }
                    }
                }
            }
            catch
            {
                // Likely a corrupt file, Just return the empty dictionary
                metadataDictionary.Clear();
            }
            return(metadataDictionary);
        }