Skip to content

Commit 9c5ad98

Browse files
committed
add XML docs, bump version numbers
1 parent e91083d commit 9c5ad98

23 files changed

+460
-53
lines changed

doc/main.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Enables MagicImageProcessor's planar format pipeline for images stored in planar
99
Most image processing software will convert YCbCr JPEG input to RGB for processing and then convert back to YCbCr for JPEG output. In addition to saving the processing time spent on this unnecessary conversion, planar processing allows for other work savings.
1010

1111
* [Chroma subsampled](https://en.wikipedia.org/wiki/Chroma_subsampling) images do not need to have their chroma planes upsampled to the luma size, only to have them rescaled again. MagicScaler can scale the subsampled chroma plane directly to its final size.
12-
* When saving in a chroma subsampled format, the final chroma scaling is done with a high-quality resampler rather than the Linear resampler used by the encoder.
13-
* When processing in [linear light](http://web.archive.org/web/20160826144709/http://www.4p8.com/eric.brasseur/gamma.html), gamma correction needs only be performed on the luma plane.
12+
* When saving in a chroma subsampled format, the final chroma scaling is done with a high-quality resampler rather than the default resampler used by the encoder.
13+
* When processing in [linear light](http://www.ericbrasseur.org/gamma.html), gamma correction needs only be performed on the luma plane.
1414
* When sharpening is applied, it also needs only be performed on the luma plane.
1515

1616
This feature is only available if WIC supports it (Windows 8.1/Windows Server 2012 and above) and the input image format is YCbCr. The output results will be slightly different than those produced with RGB processing but no less correct or visually appealing.
@@ -19,21 +19,21 @@ Default Value: true
1919

2020
### EnableSimd : static bool
2121

22-
Enables [SIMD](https://en.wikipedia.org/wiki/SIMD) versions of MagicScaler's image convolution and matting/compositing algorithms. For high-quality resampling, SIMD processing yields significant performance improvements. This is most notable with linear light processing, which now has no performance penalty compared with sRGB processing.
23-
24-
If processing predominately with low-quality resampling or in sRGB blending mode, there can be a slight performance penalty for SIMD processing. You can disable this if your use cases do not follow the high-quality MagicScaler defaults.
22+
Enables [SIMD](https://en.wikipedia.org/wiki/SIMD) versions of many of MagicScaler's algorithms. For high-quality resampling, SIMD processing yields significant performance improvements.
2523

2624
Note that the SIMD processing is done in floating point whereas the standard processing is done in fixed point math. This will result in very slight output differences due to rounding. Differences will not be visually significant but can be detected with a binary compare.
2725

26+
This property should only be used for testing/troubleshooting. Forcing floating point processing on incompatible hardware or runtimes will result in very poor performance, and disabling it when supported will sacrifice much of MagicScaler's current and future optimization.
27+
2828
Default Value: true if the runtime/JIT and hardware support hardware-accelerated System.Numerics.Vectors, otherwise false
2929

3030
### ProcessImage(string, Stream, ProcessImageSettings)
3131

3232
Accepts a file path for the input image, a stream for the output image, and a [ProcessImageSettings](#processimagesettings) object for settings. The output stream must allow Seek and Write. Returns a [ProcessImageResult](#processimageresult).
3333

34-
### ProcessImage(ArraySegment<byte>, Stream, ProcessImageSettings)
34+
### ProcessImage(ReadOnlySpan<byte>, Stream, ProcessImageSettings)
3535

36-
Accepts a byte ArraySegment for the input image, a stream for the output image, and a [ProcessImageSettings](#processimagesettings) object for settings. The output stream must allow Seek and Write. Returns a [ProcessImageResult](#processimageresult).
36+
Accepts a ReadOnlySpan for the input image, a stream for the output image, and a [ProcessImageSettings](#processimagesettings) object for settings. The output stream must allow Seek and Write. Returns a [ProcessImageResult](#processimageresult).
3737

3838
### ProcessImage(Stream, Stream, ProcessImageSettings)
3939

@@ -47,9 +47,9 @@ Accepts an [IPixelSource](#ipixelsource) input, a stream for the output image, a
4747

4848
Accepts a file path for the input image and a [ProcessImageSettings](#processimagesettings) object for settings. Returns a [ProcessingPipeline](#processingpipeline) for custom processing.
4949

50-
### BuildPipeline(ArraySegment<byte>, ProcessImageSettings)
50+
### BuildPipeline(ReadOnlySpan<byte>, ProcessImageSettings)
5151

52-
Accepts a byte ArraySegment for the input image and a [ProcessImageSettings](#processimagesettings) object for settings. Returns a [ProcessingPipeline](#processingpipeline) for custom processing.
52+
Accepts a ReadOnlySpan for the input image and a [ProcessImageSettings](#processimagesettings) object for settings. Returns a [ProcessingPipeline](#processingpipeline) for custom processing.
5353

5454
### BuildPipeline(Stream, ProcessImageSettings)
5555

@@ -187,6 +187,18 @@ An [UnsharpMaskSettings](#unsharpmasksettings) object specifying sharpening sett
187187

188188
Default value: unset
189189

190+
### ColorProfileMode : ColorProfileMode
191+
192+
A [ColorProfileMode](#colorprofilemode) value indicating how embedded [ICC Color Profiles](https://en.wikipedia.org/wiki/ICC_profile) are handled during processing.
193+
194+
Default value: Normalize
195+
196+
### OrientationMode : OrientationMode
197+
198+
An [OrientationMode](#orientationmode) value indicating how [Exif Orientation](https://magnushoff.com/jpeg-orientation.html) correction is handled during processing.
199+
200+
Default value: Normalize
201+
190202
## CropAnchor
191203

192204
A flags enumeration for specifying auto-crop anchor.
@@ -255,11 +267,11 @@ An enumeration for specifying the light blending mode used for high-quality scal
255267

256268
### Linear
257269

258-
Perform the high-quality scaling in [linear light](http://web.archive.org/web/20160826144709/http://www.4p8.com/eric.brasseur/gamma.html) colorspace. This will give better results in most cases but at a performance cost.
270+
Convert values to linear RGB before blending. This is more [mathematically correct](http://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/) and more visually pleasing in most cases.
259271

260-
### sRGB
272+
### Companded
261273

262-
Perform the high-quality scaling in gamma-corrected sRGB colorspace. This will yield output more similar to other scaling software but will be less correct in most cases.
274+
Blend companded R'G'B' values directly. This is usually a poor choice but may be used for compatibility with other software or where speed is more important than image quality.
263275

264276
## ChromaSubsampleMode
265277

@@ -313,6 +325,42 @@ JPEG. Use JpegQuality and JpegSubsampleMode settings to control output.
313325

314326
Uncompressed 24-bit or 32-bit TIFF, depending on whether or not the input image contains an alpha channel.
315327

328+
## ColorProfileMode
329+
330+
An enumeration for indicating how embedded [ICC Color Profiles](https://en.wikipedia.org/wiki/ICC_profile) are handled.
331+
332+
### Normalize
333+
334+
Convert the input image to the [sRGB color space](https://en.wikipedia.org/wiki/SRGB) during processing. Output an untagged sRGB image.
335+
336+
### NormalizeAndEmbed
337+
338+
Convert the input image to the sRGB color space during processing. Embed a [compact sRGB profile](https://github.com/saucecontrol/Compact-ICC-Profiles) in the output. This option ensures maximum compatibility with web browsers and other software but results slightly larger (+456 bytes) output files.
339+
340+
### Preserve
341+
342+
Preserve the input image color space during processing. Embed the ICC profile in the output image. If the output format does not support embedded profiles, it will be discarded. Use this option only if the output format and viewing software support color management.
343+
344+
### Ignore
345+
346+
Ignore any embedded profiles and treat the image as sRGB data. Do not tag the output image. This option may result in significant changes to output color and should only be used if the embedded profile is known to be incorrect.
347+
348+
## OrientationMode
349+
350+
An enumeration for indicating how [Exif Orientation](https://magnushoff.com/jpeg-orientation.html) is handled.
351+
352+
### Normalize
353+
354+
Correct the image orientation according to the Exif tag on load. Save the output in normal orientation. This option ensures maximum compatibility with viewer software.
355+
356+
### Preserve
357+
358+
Preserve the orientation of the input image and tag the output image to reflect the orientation. If the output format does not support orientation tagging, it will be discarded. Use this option only if the output format and viewing software support orientation correction.
359+
360+
### Ignore
361+
362+
Ignore any orientation tag and treat the image as if its stored orientation is normal. Do not tag the output image. This option should only be used if the Exif orientation of the input image is known to be incorrect.
363+
316364
## UnsharpMaskSettings
317365

318366
A structure for specifying the settings used for the post-resize [sharpening](https://en.wikipedia.org/wiki/Unsharp_masking) of the output image. These settings are designed to function similarly to the Unsharp Mask settings in Photoshop.
@@ -505,4 +553,4 @@ True if the image frame has a separate alpha channel or if it is in an indexed f
505553

506554
### ExifOrientation: Orientation
507555

508-
The [Exif Orientation](http://www.impulseadventure.com/photo/exif-orientation.html) value stored for this image frame. The Width and Height values are pre-corrected according to this value, so you can ignore it if you are using MagicScaler to process the image, as it performs orientation correction automatically. The integer values defined in the Orientation enumeration match the stored Exif values.
556+
The [Exif Orientation](https://magnushoff.com/jpeg-orientation.html) value stored for this image frame. The Width and Height values are pre-corrected according to this value, so you can ignore it if you are using MagicScaler to process the image, as it performs orientation correction automatically. The integer values defined in the Orientation enumeration match the stored Exif values.

readme.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,6 @@ WebRSize must be configured in your application's web.config file. It will not
6565
See the [documentation page](doc/web.md) for more details.
6666

6767

68-
Release History
69-
---------------
70-
#### MagicScaler 0.8.4.0
71-
* Fixed an issue that caused sharpening to be a no-op when working with some pixel formats in sRGB blending mode.
72-
* Improved quality of scaling and sharpening with partially-transparent images.
73-
* Added [GitLink](https://github.com/GitTools/GitLink) to enable github source server support for debugging.
74-
75-
#### WebRSize 0.3.2.0
76-
* Fixed incorrect file extension for 404 images in the disk cache
77-
* Added exception handler for "Client Disconnected" errors when transmitting images from the HttpHandler
78-
* Added devicePixelRatio (dpr) setting to enable automatic size and quality adjustments for retina clients
79-
* Added "q" shortcut for quality setting
80-
81-
See the [releases page](https://github.com/saucecontrol/PhotoSauce/releases) for previous updates.
82-
8368
Versioning
8469
----------
8570

@@ -88,7 +73,7 @@ This project is using [semantic versioning](http://semver.org/). Releases witho
8873
Contributing
8974
------------
9075

91-
Because this project is still under active design and development, I am not accepting unsolicited pull requests at this time. If you find a bug or would like to see a new feature implemented, please open a new issue for further discussion. This will hopefully save any wasted or duplicate efforts. If we can agree on a direction, help would be most welcome.
76+
Contributions are welcome, but please open a new issue for discussion before submitting any pull requests. This will hopefully save any wasted or duplicate efforts.
9277

9378
License
9479
-------

src/MagicScaler/Core/ImageFileInfo.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,29 @@
33

44
namespace PhotoSauce.MagicScaler
55
{
6+
/// <summary>Represents basic information about an image container.</summary>
67
public sealed class ImageFileInfo
78
{
9+
/// <summary>Represents basic information about an image frame within a container.</summary>
810
public readonly struct FrameInfo
911
{
12+
/// <summary>The width of the image frame in pixels.</summary>
1013
public int Width { get; }
14+
/// <summary>The height of the image frame in pixels.</summary>
1115
public int Height { get; }
16+
/// <summary>True if the image frame contains transparency data, otherwise false.</summary>
1217
public bool HasAlpha { get; }
18+
/// <summary>
19+
/// The stored <a href="https://magnushoff.com/jpeg-orientation.html">Exif orientation</a> for the image frame.
20+
/// The <see cref="Width" /> and <see cref="Height" /> values reflect the corrected orientation, not the stored orientation.
21+
/// </summary>
1322
public Orientation ExifOrientation { get; }
1423

24+
/// <summary>Constructs a new <see cref="FrameInfo" /> instance with the supplied values.</summary>
25+
/// <param name="width">The width of the image frame in pixels.</param>
26+
/// <param name="height">The height of the image frame in pixels.</param>
27+
/// <param name="hasAlpha">True if the image frame contains transparency data, otherwise false.</param>
28+
/// <param name="orientation">The Exif orientation associated with the image frame.</param>
1529
public FrameInfo(int width, int height, bool hasAlpha, Orientation orientation)
1630
{
1731
Width = width;
@@ -21,17 +35,26 @@ public FrameInfo(int width, int height, bool hasAlpha, Orientation orientation)
2135
}
2236
}
2337

38+
/// <summary>The size of the image container in bytes.</summary>
2439
public long FileSize { get; private set; }
40+
/// <summary>The last modified date of the image container, if applicable.</summary>
2541
public DateTime FileDate { get; private set; }
42+
/// <summary>The format of the image container (e.g. JPEG, PNG).</summary>
2643
public FileFormat ContainerType { get; private set; }
44+
/// <summary>One or more <see cref="FrameInfo" /> instances describing each image frame in the container.</summary>
2745
public FrameInfo[] Frames { get; private set; }
2846

47+
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance with a single frame of the specified <paramref name="width" /> and <paramref name="height" />.</summary>
48+
/// <param name="width">The width of the image frame in pixels.</param>
49+
/// <param name="height">The height of the image frame in pixels.</param>
2950
public ImageFileInfo(int width, int height)
3051
{
3152
Frames = new[] { new FrameInfo(width, height, false, Orientation.Normal) };
3253
ContainerType = FileFormat.Unknown;
3354
}
3455

56+
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance by reading the metadata from an image file header.</summary>
57+
/// <param name="imgPath">The path to the image file.</param>
3558
public ImageFileInfo(string imgPath)
3659
{
3760
var fi = new FileInfo(imgPath);
@@ -45,8 +68,12 @@ public ImageFileInfo(string imgPath)
4568
FileDate = fi.LastWriteTimeUtc;
4669
}
4770

71+
/// <inheritdoc cref="ImageFileInfo(ReadOnlySpan{byte}, DateTime)" />
4872
public ImageFileInfo(ReadOnlySpan<byte> imgBuffer) : this(imgBuffer, DateTime.MinValue) { }
4973

74+
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance by reading the metadata from an image file contained in a <see cref="ReadOnlySpan{T}" />.</summary>
75+
/// <param name="imgBuffer">The buffer containing the image data.</param>
76+
/// <param name="lastModified">The last modified date of the image container.</param>
5077
public ImageFileInfo(ReadOnlySpan<byte> imgBuffer, DateTime lastModified)
5178
{
5279
if (imgBuffer == default) throw new ArgumentNullException(nameof(imgBuffer));
@@ -58,8 +85,12 @@ public ImageFileInfo(ReadOnlySpan<byte> imgBuffer, DateTime lastModified)
5885
FileDate = lastModified;
5986
}
6087

88+
/// <inheritdoc cref="ImageFileInfo(Stream, DateTime)" />
6189
public ImageFileInfo(Stream imgStream) : this(imgStream, DateTime.MinValue) { }
6290

91+
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance by reading the metadata from an image file exposed by a <see cref="Stream" />.</summary>
92+
/// <param name="imgStream">The stream containing the image data.</param>
93+
/// <param name="lastModified">The last modified date of the image container.</param>
6394
public ImageFileInfo(Stream imgStream, DateTime lastModified)
6495
{
6596
if (imgStream is null) throw new ArgumentNullException(nameof(imgStream));

0 commit comments

Comments
 (0)