Table of Contents

Class ImageOptimizer

Namespace
ImageMagick
Assembly
Magick.NET-Q16-AnyCPU.dll

Class that can be used to optimize an image.

public sealed class ImageOptimizer
Inheritance
ImageOptimizer
Inherited Members

Constructors

ImageOptimizer()

public ImageOptimizer()

Properties

IgnoreUnsupportedFormats

Gets or sets a value indicating whether to skip unsupported files instead of throwing an exception.

public bool IgnoreUnsupportedFormats { get; set; }

Property Value

bool

OptimalCompression

Gets or sets a value indicating whether various compression types will be used to find the smallest file. This process will take extra time because the file has to be written multiple times.

public bool OptimalCompression { get; set; }

Property Value

bool

Methods

Compress(FileInfo)

Performs compression on the specified file. With some formats the image will be decoded and encoded and this will result in a small quality reduction. If the new file size is not smaller the file won't be overwritten.

public bool Compress(FileInfo file)

Parameters

file FileInfo

The image file to compress.

Returns

bool

True when the image could be compressed otherwise false.

Compress(Stream)

Performs compression on the specified stream. With some formats the image will be decoded and encoded and this will result in a small quality reduction. If the new size is not smaller the stream won't be overwritten.

public bool Compress(Stream stream)

Parameters

stream Stream

The stream of the image to compress.

Returns

bool

True when the image could be compressed otherwise false.

Compress(string)

Performs compression on the specified file. With some formats the image will be decoded and encoded and this will result in a small quality reduction. If the new file size is not smaller the file won't be overwritten.

public bool Compress(string fileName)

Parameters

fileName string

The file name of the image to compress.

Returns

bool

True when the image could be compressed otherwise false.

IsSupported(IMagickFormatInfo?)

Returns true when the supplied formation information is supported.

public bool IsSupported(IMagickFormatInfo? formatInfo)

Parameters

formatInfo IMagickFormatInfo

The format information to check.

Returns

bool

True when the supplied formation information is supported.

IsSupported(FileInfo)

Returns true when the supplied file name is supported based on the extension of the file.

public bool IsSupported(FileInfo file)

Parameters

file FileInfo

The file to check.

Returns

bool

True when the supplied file name is supported based on the extension of the file.

IsSupported(Stream)

Returns true when the supplied stream is supported.

public bool IsSupported(Stream stream)

Parameters

stream Stream

The stream to check.

Returns

bool

True when the supplied stream is supported.

IsSupported(string)

Returns true when the supplied file name is supported based on the extension of the file.

public bool IsSupported(string fileName)

Parameters

fileName string

The name of the file to check.

Returns

bool

True when the supplied file name is supported based on the extension of the file.

LosslessCompress(FileInfo)

Performs lossless compression on the specified file. If the new file size is not smaller the file won't be overwritten.

public bool LosslessCompress(FileInfo file)

Parameters

file FileInfo

The image file to compress.

Returns

bool

True when the image could be compressed otherwise false.

LosslessCompress(Stream)

Performs lossless compression on the specified stream. If the new stream size is not smaller the stream won't be overwritten.

public bool LosslessCompress(Stream stream)

Parameters

stream Stream

The stream of the image to compress.

Returns

bool

True when the image could be compressed otherwise false.

LosslessCompress(string)

Performs lossless compression on the specified file. If the new file size is not smaller the file won't be overwritten.

public bool LosslessCompress(string fileName)

Parameters

fileName string

The file name of the image to compress.

Returns

bool

True when the image could be compressed otherwise false.