diff --git a/doc/main.md b/doc/main.md index d1ee0e3d..90bbaf9b 100644 --- a/doc/main.md +++ b/doc/main.md @@ -46,31 +46,31 @@ Default Value: 0 ###Sharpen: bool -Indicates whether an [unsharp mask](https://en.wikipedia.org/wiki/Unsharp_masking) operation should be performed on the image following the resize. The sharpening settings are controlled by the [UnsharpMask](#UnsharpMask) property. +Indicates whether an [unsharp mask](https://en.wikipedia.org/wiki/Unsharp_masking) operation should be performed on the image following the resize. The sharpening settings are controlled by the [UnsharpMask](#unsharpmask-unsharpmasksettings) property. Default value: false ###ResizeMode: CropScaleMode -A [CropScaleMode](#CropScaleMode) value indicating whether auto-cropping should be performed or whether the resized image may have a different aspect ratio. Auto-cropping is performed only if a [Crop](#Crop) value is not explicitly set. +A [CropScaleMode](#cropscalemode) value indicating whether auto-cropping should be performed or whether the resized image may have a different aspect ratio. Auto-cropping is performed only if a [Crop](#crop-rectangle) value is not explicitly set. Default value: Crop ###Crop: Rectangle -A System.Drawing.Rectangle that specifies which part of the input image should be included. If the rectangle is empty and the [ResizeMode](#ResizeMode) is set to `Crop`, the image will be cropped automatically. Points given for this rectangle must be expressed in terms of the input image. +A System.Drawing.Rectangle that specifies which part of the input image should be included. If the rectangle is empty and the [ResizeMode](#resizemode-cropscalemode) is set to `Crop`, the image will be cropped automatically. Points given for this rectangle must be expressed in terms of the input image. Default value: Rectangle.Empty ###Anchor: CropAnchor -A [CropAnchor](#CropAnchor) value indicating the position of the auto-crop rectangle. Values may be combined to specify a vertical and horizontal position. Ex: `myCrop = CropAnchor.Top | CropAnchor.Left`. +A [CropAnchor](#cropanchor) value indicating the position of the auto-crop rectangle. Values may be combined to specify a vertical and horizontal position. Ex: `myCrop = CropAnchor.Top | CropAnchor.Left`. Default value: CropAnchor.Center ###SaveFormat: FileFormat -A [FileFormat](#FileFormat) value indicating the codec used for the output image. A value of `Auto` will choose the output codec based on the input image type. +A [FileFormat](#fileformat) value indicating the codec used for the output image. A value of `Auto` will choose the output codec based on the input image type. Default value: FileFormat.Auto @@ -82,13 +82,13 @@ Default value: Color.Empty ###HybridMode: HybridScaleMode -A [HybridScaleMode](#HybridScaleMode) value indicating whether hybrid processing is allowed. Hybrid processing may use the image decoder or another low-quality scaler to shrink an image to an intermediate size before the selected high-quality algorithm is applied to the final resize. This can result in dramatic performance improvements but with a reduction in image quality. +A [HybridScaleMode](#hybridscalemode) value indicating whether hybrid processing is allowed. Hybrid processing may use the image decoder or another low-quality scaler to shrink an image to an intermediate size before the selected high-quality algorithm is applied to the final resize. This can result in dramatic performance improvements but with a reduction in image quality. Default value: HybridScaleMode.FavorQuality ###BlendingMode: GammaMode -A [GammaMode](#GammaMode) value indicating whether the scaling algorithm is applied in linear or gamma-corrected colorspace. Linear processing will yield better quality in almost all cases but with a performance cost. +A [GammaMode](#gammamode) value indicating whether the scaling algorithm is applied in linear or gamma-corrected colorspace. Linear processing will yield better quality in almost all cases but with a performance cost. Default value: GammaMode.Linear @@ -106,19 +106,19 @@ Default value: 0 ###JpegSubsampleMode: ChromaSubsampleMode -A [ChromaSubsampleMode](#ChromaSubsampleMode) value indicating how [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling) is configured in the JPEG encoder for the output image. If this value is set to `Default`, the chroma subsampling will be set automatically based on the [JpegQuality](#JpegQuality) setting. +A [ChromaSubsampleMode](#chromasubsamplemode) value indicating how [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling) is configured in the JPEG encoder for the output image. If this value is set to `Default`, the chroma subsampling will be set automatically based on the [JpegQuality](#jpegquality-int) setting. Default value: ChromaSubsampleMode.Default ###Interpolation: InterpolationSettings -An [InterpolationSettings](#InterpolationSettings) object specifying details of the sampling algorithm to use for image scaling. If this value is unset, the algorithm will be chosen automatically based on the ratio of input image size to output image size. +An [InterpolationSettings](#interpolationsettings) object specifying details of the sampling algorithm to use for image scaling. If this value is unset, the algorithm will be chosen automatically based on the ratio of input image size to output image size. Default value: unset ###UnsharpMask: UnsharpMaskSettings -An [UnsharpMaskSettings](#UnsharpMaskSettings) object specifying sharpening settings. If this value is unset, the settings will be chosen automatically based on the ratio of input image size to output image size. +An [UnsharpMaskSettings](#unsharpmasksettings) object specifying sharpening settings. If this value is unset, the settings will be chosen automatically based on the ratio of input image size to output image size. Default value: unset @@ -153,7 +153,7 @@ Allow the output image Width and Height to change the aspect ratio of the input ###Examples Suppose you have an input image with dimensions of 640x480 and you set the Width and Height of the output image to 100x100. -`Crop` will produce an output image of 100x100, preserving the aspect ratio of the input image by cropping from the sides of the image. By default, this will crop evenly from the left and right. You can change that behavior by changing the [Anchor](#CropAnchor) value. +`Crop` will produce an output image of 100x100, preserving the aspect ratio of the input image by cropping from the sides of the image. By default, this will crop evenly from the left and right. You can change that behavior by changing the [Anchor](#anchor-cropanchor) value. `Max` will produce an output image of 100x75, preserving the aspect ratio of the input image by contstraining the dimensions of the output image. `Stretch` will produce an output image of 100x100 that is squished horizontally. diff --git a/readme.md b/readme.md index 8bfb856f..75c46d92 100644 --- a/readme.md +++ b/readme.md @@ -6,8 +6,7 @@ MagicScaler brings hig-performance, high-quality image scaling to .NET. Requirements ------------ -Windows 7 SP1 or later* -.NET 4.6 or later +Windows 7* or later with .NET 4.6 or later *Windows 7 and Windows Sever 2008 R2 are supported only with the [Platform Update](https://support.microsoft.com/en-us/kb/2670838) installed. @@ -40,6 +39,8 @@ Release History --------------- ####0.6.0.0 +* Fixed invalid color profile error when using hybrid scaling with non-JPEG CMYK images. +* Enabled sharpening by default. This can be disabled with the Sharpen property on ProcessImageSettings. * Added support for copying metadata from the source image. See the MetadataNames property on ProcessImageSettings. * Added CubicSmoother preconfigured interpolator. * Changed Lanczos filter default to 3 lobes. Removed the preconfigured 2-lobe filter and changed the name of Lanczos3 to Lanczos. diff --git a/src/Core/ColorProfileReader.cs b/src/Core/ColorProfileReader.cs index e77c449f..28034c2b 100644 --- a/src/Core/ColorProfileReader.cs +++ b/src/Core/ColorProfileReader.cs @@ -20,7 +20,7 @@ internal class ColorProfileInfo public string Creator { get; private set; } public bool IsValid { get; private set; } - public bool IsDisplayRgb => DataColorSpace == "RGB " && DeviceClass == "mntr"; + public bool IsDisplayRgb => DataColorSpace == "RGB " && (DeviceClass == "mntr" || DeviceClass == "cmra" || DeviceClass == "scnr"); public bool IsCmyk => DataColorSpace == "CMYK"; public bool IsStandardSrgb => CMM == "Lino" && Manufacturer == "IEC " && Model == "sRGB"; diff --git a/src/Core/ProcessImageSettings.cs b/src/Core/ProcessImageSettings.cs index 27c713b3..0b52a73f 100644 --- a/src/Core/ProcessImageSettings.cs +++ b/src/Core/ProcessImageSettings.cs @@ -79,7 +79,7 @@ public class ProcessImageSettings public int FrameIndex { get; set; } public int Width { get; set; } public int Height { get; set; } - public bool Sharpen { get; set; } + public bool Sharpen { get; set; } = true; public CropScaleMode ResizeMode { get; set; } public Rectangle Crop { get; set; } public CropAnchor Anchor { get; set; } diff --git a/src/WIC/MagicImageProcessor.cs b/src/WIC/MagicImageProcessor.cs index 74879874..65f13740 100644 --- a/src/WIC/MagicImageProcessor.cs +++ b/src/WIC/MagicImageProcessor.cs @@ -64,9 +64,9 @@ private static void processImage(WicDecoder dec, WicProcessingContext ctx, Strea using (var cac = new WicConditionalCache(rot)) using (var crp = new WicCropper(cac)) using (var pix = new WicPixelFormatConverter(crp)) - using (var res = new WicScaler(pix, true)) - using (var cmy = new WicCmykConverter(res)) - using (var lll = new WicGammaExpand(cmy)) + using (var cmy = new WicCmykConverter(pix)) + using (var res = new WicScaler(cmy, true)) + using (var lll = new WicGammaExpand(res)) using (var mmm = new WicHighQualityScaler(lll)) using (var mat = new WicMatteTransform(mmm)) using (var ggg = new WicGammaCompress(mat)) diff --git a/src/WIC/WicImageProcessor.cs b/src/WIC/WicImageProcessor.cs index 92135be4..c398bd64 100644 --- a/src/WIC/WicImageProcessor.cs +++ b/src/WIC/WicImageProcessor.cs @@ -43,7 +43,8 @@ private static void processImage(WicDecoder dec, WicProcessingContext ctx, Strea using (var cac = new WicConditionalCache(rot)) using (var crp = new WicCropper(cac)) using (var pix = new WicPixelFormatConverter(crp)) - using (var res = new WicScaler(pix)) + using (var cmy = new WicCmykConverter(pix)) + using (var res = new WicScaler(cmy)) using (var csc = new WicColorspaceConverter(res)) using (var mat = new WicMatteTransform(csc)) using (var pal = new WicPaletizer(mat, 256)) diff --git a/src/WIC/WicTransform.cs b/src/WIC/WicTransform.cs index 2e6c71db..7770d29e 100644 --- a/src/WIC/WicTransform.cs +++ b/src/WIC/WicTransform.cs @@ -203,7 +203,6 @@ public WicCmykConverter(WicTransform prev) : base(prev) if (!Context.IsCmyk) return; - // TODO 40bppcmyka unsupported -- WIC bug var trans = AddRef(Wic.CreateColorTransform()); trans.Initialize(Source, Context.SourceColorContext, Context.DestColorContext, Context.HasAlpha ? Consts.GUID_WICPixelFormat32bppBGRA : Consts.GUID_WICPixelFormat24bppBGR);