diff --git a/doc/web.md b/doc/web.md index 74489d5e..98c79868 100644 --- a/doc/web.md +++ b/doc/web.md @@ -36,7 +36,7 @@ The `WebRSizeModule` must receive event notifications for static image requests ``` -Omit the `preCondition` attribute on the module entry to ensure it will see all requests, managed or not. The `WebRSizeModule` detects when it has been manually registered and will skip self-registration. This option will always work and is the safe way to go if you are in doubt. + Omit the `preCondition` attribute on the module entry to ensure it will see all requests, managed or not. The `WebRSizeModule` detects when it has been manually registered and will skip self-registration. This option will always work and is the safe way to go if you are in doubt. 3. You can set up an explicit handler mapping for image file extension you want to process that maps to a managed `IHttpHandler`. @@ -47,7 +47,7 @@ Omit the `preCondition` attribute on the module entry to ensure it will see all ``` -This is common in scenarios where images will be served from a `VirtualPathProvider` that uses a database or cloud storage. The built-in `StaticFileHandler` will request files from the registered `VirtualPathProvider`, and because the handler is managed, the self-registered `WebRSizeModule` instance will be able to intercept image processing requests. + This is common in scenarios where images will be served from a `VirtualPathProvider` that uses a database or cloud storage. The built-in `StaticFileHandler` will request files from the registered `VirtualPathProvider`, and because the handler is managed, the self-registered `WebRSizeModule` instance will be able to intercept image processing requests. ## Configuration Reference diff --git a/readme.md b/readme.md index dc129c24..257a6e30 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ MagicScaler =========== -MagicScaler brings high-performance, high-quality image scaling to .NET. +High-performance image processing pipeline for .NET. Implements best-of-breed algorithms, linear light processing, and sharpening for the best image resizing quality available. Speed and efficiency are unmatched by anything else on the .NET platform. Requirements ------------ @@ -26,9 +26,15 @@ Basic usage looks something like this: ```C# using (var outStream = new FileStream(@"c:\smallimage.jpg", FileMode.Create)) +{ MagicImageProcessor.ProcessImage(@"c:\bigimage.jpg", outStream, new ProcessImageSettings { Width = 400 }); +} ``` +The above example will resize `bigimage.jpg` to a width of 400 pixels and save the output to `smallimage.jpg`. The height will be set automatically to preserve the correct aspect ratio. Default settings are optimized for a balance of speed and image quality. + +The MagicScaler pipleline is also customizable if you wish to use an alternate pixel source, capture the output pixels for additional processing, or add custom filtering. + See the [documentation page](doc/main.md) for more details. @@ -61,44 +67,20 @@ See the [documentation page](doc/web.md) for more details. Release History --------------- -#### MagicScaler 0.8.2.0 -* No longer throws an exception if an image contains an invalid embedded ICC profile. Color management is silently skipped in these cases. - -#### MagicScaler 0.8.1.0 -* Fixed "Unsupported Pixel Format" error when converting 16-bit CMYK to RGB formats using an ICC profile - -#### MagicScaler 0.8.0.0 -NOTE: This version contains breaking changes to the API. While your code will most likely not require changes, you will have to rebuild when upgrading. - -* Changed parameter names on public methods to be more descriptive. -* Changed ProcessImage() overloads that accepted byte[] to accept ArraySegment<byte>. -* Added metadata support (including Exif auto-rotation) to the .NET Core version. -* Added ImageFileInfo class to expose basic information read from image headers. -* Added IPixelSource interface to allow clients to feed pixels into the pipeline from custom sources. -* Added IPixelTransform class to allow custom filtering. -* Added ProcessingPipeline class to allow clients to request pixels from the pipeline without saving directly to an image file. -* Added ProcessImageResults class to expose calculated settings used and basic instrumentation. -* Added sample IPixelSource and IPixelTransform implementations. -* Improved fixed-point math accuracy for non-SIMD implementation. -* Improved RGBA performance in SIMD implementation. -* Improved Auto output format logic to match WebRSize. -* Fixed invalid crop values when using Hybrid scaling. -* Fixed invalid crop offsets when using Planar mode. -* UnsharpMaskSettings no longer overrides the Sharpen setting. If Sharpen is false, there will be no auto-sharpening regardless of UnsharpMaskSettings. - -#### WebRSize 0.3.0.0 -NOTE: Cache file naming has changed in this version. You should empty your WebRSize disk cache when upgrading. - -* Changed cache file name generator to use the correct file extension when transcoding to a different format. -* Fixed a bug in the cache file name generator that caused duplicate cache files. -* Improved speed and reduced allocations in the HTTP intercept module. +#### WebRSize 0.3.1.0 +* Require MagicScaler 0.8.3 or later +* Fix nuget config transform to place `configSections` as the first child of `configuration` + +#### MagicScaler 0.8.3.0 +* Fixed image corruption (and possible access violation) when sharpening BGR/BGRA images in sRGB blending mode. +* Use latest System.Buffers version for .NET Framework installations See the [releases page](https://github.com/saucecontrol/PhotoSauce/releases) for previous updates. Versioning ---------- -This project is using [semantic versioning](http://semver.org/). Releases without an alpha/beta/RC tag are considered release quality and are safe for production use. The major version number will remain at 0, however, until the APIs are complete and stabilized. You can expect significant API changes coming in MagicScaler 0.8. +This project is using [semantic versioning](http://semver.org/). Releases without an alpha/beta/RC tag are considered release quality and are safe for production use. The major version number will remain at 0, however, until the APIs are complete and stabilized. Contributing ------------ diff --git a/src/MagicScaler/Interop/PropVariant.cs b/src/MagicScaler/Interop/PropVariant.cs index 6e215691..074e5851 100644 --- a/src/MagicScaler/Interop/PropVariant.cs +++ b/src/MagicScaler/Interop/PropVariant.cs @@ -202,7 +202,7 @@ unsafe public IntPtr MarshalManagedToNative(object o) int cbNative = Marshal.SizeOf(); var pNativeData = Marshal.AllocCoTaskMem(cbNative); - Unsafe.InitBlock(pNativeData.ToPointer(), default(byte), (uint)cbNative); + Unsafe.InitBlock(pNativeData.ToPointer(), default, (uint)cbNative); if (o == null) return pNativeData; diff --git a/src/MagicScaler/Interop/WinCodec.cs b/src/MagicScaler/Interop/WinCodec.cs index fd80606c..ef222546 100644 --- a/src/MagicScaler/Interop/WinCodec.cs +++ b/src/MagicScaler/Interop/WinCodec.cs @@ -77,7 +77,9 @@ internal enum WinCodecError WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT = unchecked((int)0x88982f92), WINCODEC_ERR_INVALIDQUERYCHARACTER = unchecked((int)0x88982f93), WINCODEC_ERR_WIN32ERROR = unchecked((int)0x88982f94), - WINCODEC_ERR_INVALIDPROGRESSIVELEVEL = unchecked((int)0x88982f95) + WINCODEC_ERR_INVALIDPROGRESSIVELEVEL = unchecked((int)0x88982f95), + + ERROR_INVALID_PROFILE = unchecked((int)0x800707DB) } [Flags] diff --git a/src/MagicScaler/Magic/ConvolutionTransform.cs b/src/MagicScaler/Magic/ConvolutionTransform.cs index 2b30120d..e724876a 100644 --- a/src/MagicScaler/Magic/ConvolutionTransform.cs +++ b/src/MagicScaler/Magic/ConvolutionTransform.cs @@ -60,7 +60,8 @@ public ConvolutionTransform(PixelSource source, KernelMap mapx, KernelM if (fmt.ColorRepresentation == PixelColorRepresentation.Bgr || fmt.ColorRepresentation == PixelColorRepresentation.Grey) fmt = fmt.NumericRepresentation == PixelNumericRepresentation.Float ? PixelFormat.Cache[Consts.GUID_WICPixelFormat32bppGrayFloat] : fmt.NumericRepresentation == PixelNumericRepresentation.Fixed ? PixelFormat.Grey16BppUQ15 : - Format; + fmt.NumericRepresentation == PixelNumericRepresentation.UnsignedInteger ? PixelFormat.Cache[Consts.GUID_WICPixelFormat8bppGray] : + throw new NotSupportedException("Unsupported pixel format"); else throw new NotSupportedException("Unsupported pixel format"); } diff --git a/src/MagicScaler/Magic/KernelMap.cs b/src/MagicScaler/Magic/KernelMap.cs index 0f1c4597..8c46d7e8 100644 --- a/src/MagicScaler/Magic/KernelMap.cs +++ b/src/MagicScaler/Magic/KernelMap.cs @@ -104,7 +104,7 @@ unsafe private KernelMap clamp() Unsafe.Write(mpw + k, a); for (int j = 1; j < samp; j++) - Unsafe.Write(mpw + j * chan + k, j < samp - o ? Unsafe.Read(mpw + j * chan + o * chan + k) : default(T)); + Unsafe.Write(mpw + j * chan + k, j < samp - o ? Unsafe.Read(mpw + j * chan + o * chan + k) : default); } } else if (start + samp > ipix) @@ -122,7 +122,7 @@ unsafe private KernelMap clamp() Unsafe.Write(mpw + last * chan + k, a); for (int j = last - 1; j >= 0; j--) - Unsafe.Write(mpw + j * chan + k, j >= o ? Unsafe.Read(mpw + j * chan - o * chan + k) : default(T)); + Unsafe.Write(mpw + j * chan + k, j >= o ? Unsafe.Read(mpw + j * chan - o * chan + k) : default); } } diff --git a/src/MagicScaler/MagicScaler.csproj b/src/MagicScaler/MagicScaler.csproj index 7c6a053e..fa5c435d 100644 --- a/src/MagicScaler/MagicScaler.csproj +++ b/src/MagicScaler/MagicScaler.csproj @@ -8,7 +8,7 @@ 1.0.4 true latest - 0.8.2 + 0.8.3 Clinton Ingram PhotoSauce MagicScaler @@ -44,7 +44,7 @@ - + diff --git a/src/MagicScaler/Utilities/WinCodecExtensions.cs b/src/MagicScaler/Utilities/WinCodecExtensions.cs index bd99ed6a..76576aa8 100644 --- a/src/MagicScaler/Utilities/WinCodecExtensions.cs +++ b/src/MagicScaler/Utilities/WinCodecExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; namespace PhotoSauce.MagicScaler.Interop { @@ -67,6 +68,9 @@ public static bool TrySetMetadataByName(this IWICMetadataQueryWriter meta, strin public static bool TryInitialize(this IWICColorTransform trans, IWICBitmapSource source, IWICColorContext ctxSrc, IWICColorContext ctxDest, Guid fmtDest) { int hr = ProxyFunctions.InitializeColorTransform(trans, source, ctxSrc, ctxDest, fmtDest); + if (hr < 0 && hr != (int)WinCodecError.ERROR_INVALID_PROFILE) + Marshal.ThrowExceptionForHR(hr); + return hr >= 0; } } diff --git a/src/WebRSize/WebRSize.csproj b/src/WebRSize/WebRSize.csproj index 294d47c5..4239101c 100644 --- a/src/WebRSize/WebRSize.csproj +++ b/src/WebRSize/WebRSize.csproj @@ -6,7 +6,7 @@ WebRSize net46 latest - 0.3.0 + 0.3.1 Clinton Ingram Web extensions for the MagicScaler library, inlcluding an HTTP request intercept module for automatic image processing. PhotoSauce