internal void NormalizeFrom(ImageFileInfo img)
        {
            Contract.Requires <InvalidOperationException>(Width >= 0 && Height >= 0, "Width and Height cannot be negative");
            Contract.Requires <InvalidOperationException>(ResizeMode == CropScaleMode.Crop || (Width > 0 && Height > 0), "Width and Height must be > 0 with Stretch and Max Modes");
            Contract.Assert(FrameIndex < img.Frames.Length || img.Frames.Length + FrameIndex < 0, "Invalid FrameIndex");

            if (FrameIndex < 0)
            {
                FrameIndex = img.Frames.Length + FrameIndex;
            }

            var frame = img.Frames[FrameIndex];

            if (SaveFormat == FileFormat.Auto)
            {
                if (img.ContainerType == FileFormat.Gif)                 // Restrict to animated only?
                {
                    SaveFormat = FileFormat.Gif;
                }
                else if (img.ContainerType == FileFormat.Png || (frame.HasAlpha && MatteColor.A < 255))
                {
                    SaveFormat = FileFormat.Png;
                }
                else
                {
                    SaveFormat = FileFormat.Jpeg;
                }
            }

            if (SaveFormat != FileFormat.Jpeg)
            {
                JpegSubsampleMode = ChromaSubsampleMode.Default;
                JpegQuality       = 0;
            }

            if (!frame.HasAlpha)
            {
                MatteColor = Color.Empty;
            }

            if (!Sharpen)
            {
                UnsharpMask = UnsharpMaskSettings.None;
            }

            Fixup(frame.Width, frame.Height, frame.Rotated90);

            imageInfo = img;
        }
        internal void NormalizeFrom(ImageFileInfo img)
        {
            if (Width < 0 || Height < 0)
            {
                throw new InvalidOperationException($"{nameof(Width)} and {nameof(Height)} cannot be negative");
            }
            if (Width == 0 && Height == 0)
            {
                throw new InvalidOperationException($"{nameof(Width)} and {nameof(Height)} may not both be 0");
            }
            if ((Width == 0 || Height == 0) && ResizeMode != CropScaleMode.Crop)
            {
                throw new InvalidOperationException($"{nameof(Width)} or {nameof(Height)} may only be 0 in {nameof(CropScaleMode.Crop)} mode");
            }
            if (FrameIndex >= img.Frames.Length || img.Frames.Length + FrameIndex < 0)
            {
                throw new InvalidOperationException($"Invalid {nameof(FrameIndex)}");
            }

            if (FrameIndex < 0)
            {
                FrameIndex = img.Frames.Length + FrameIndex;
            }

            var frame = img.Frames[FrameIndex];

            if (SaveFormat == FileFormat.Auto)
            {
                if (img.ContainerType == FileFormat.Gif)                 // Restrict to animated only?
                {
                    SaveFormat = FileFormat.Gif;
                }
                else if (img.ContainerType == FileFormat.Png || (frame.HasAlpha && MatteColor.A < byte.MaxValue))
                {
                    SaveFormat = FileFormat.Png;
                }
                else
                {
                    SaveFormat = FileFormat.Jpeg;
                }
            }

            if (SaveFormat != FileFormat.Jpeg)
            {
                JpegSubsampleMode = ChromaSubsampleMode.Default;
                JpegQuality       = 0;
            }

            if (!frame.HasAlpha)
            {
                MatteColor = Color.Empty;
            }

            if (!Sharpen)
            {
                UnsharpMask = UnsharpMaskSettings.None;
            }

            Fixup(frame.Width, frame.Height, frame.Rotated90);

            imageInfo = img;
        }