CHANGES.md
Breaking Changes:
ImageDecoderRect has been removed (#2355, #2681)Features:
Pixel in a generic way (#2638)Structural changes:
rayon feature is enabled (#2643)doc_auto_cfg with doc_cfg (#2637)Bug fixes:
Re-release of 0.25.7
Fixes:
load_from_memory that lead to large scale
type inference breakage despite being technically compatible.Features:
image (#2372)Structural changes:
API improvements:
save, save_with_format, write_to and write_with_encoder methods on DynamicImage now automatically convert the pixel format when necessary instead of returning an error (#2501)DynamicImage::has_alpha() convenience methodTryFrom<ExtendedColorType> for ColorType (#2444)const HAS_ALPHA to trait Pixelhooks module to customize builtin behavior, register_format_detection_hook and register_decoding_hook for the determining format of a file and selecting an ImageDecoder implementation respectively. (#2372)Performance improvements:
Bug fixes:
GifEncoder::encode() ignoring the speed parameter and always using the slowest speed (#2504).pnm is now recognized as a file extension for the PNM format (#2559)Features:
Bug fixes:
Features:
Bug fixes:
rayon feature now correctly toggles the use of rayon when encoding AVIF. (Previously it would be either always on or always off depending on the version of the ravif crate in your dependency tree.)Features:
ImageDecoder::orientation() and implemented orientation metadata extraction for JPEG, WebP and TIFF formatsDynamicImage::apply_orientation() to apply the orientation to an imageImageDecoder::exif_metadata(), and implemented it for JPEG and WebP formatsImageEncoder::set_icc_profile() and implemented it for WebP format. Pull requests with implementations for other formats are welcome.DynamicImage::fast_blur() for a linear-time approximation of Gaussian blur, which is much faster at larger blur radiiBug fixes:
None instead of an error when the end of the animation is reachedYanked! This version accidentally missed a commit that should have been
included with the release. The Orientation struct should be in the
appropriate module instead of the top-level. This release won't be supported.
Features:
hdr feature enabled. Supports 32-bit float RGB color only, for now.ImageBuffer, DynamicImage and Frame the existing buffer
will now be reused if possible.image::ImageReader as an alias.ImageEncoder for HdrEncoder.Structural changes
byteorder to byteorder-lite, consolidating some casting
unsafety to bytemuck.DynamicImage and buffers gained #[must_use] indications.Bug fixes:
bmp decoder.exr feature now compiles in isolation.Bug fixes:
ImageFormat::{reading_enabled, writing_enabled}.Breaking changes:
BufRead + Seek bound on many decoders.ExtendedColorType instead of ColorType when encoding.ImageOutputFormat, GenericImageView::bounds, and several other
deprecated items.ImageDecoder so the trait
is object safe.repr(transparent) rather than repr(C).Structural changes:
Codec changes:
Structural changes:
New features:
Bug fixes:
New features:
DynamicImage::new method.PngDecoder::gamma_value method.ImageFormat::{reading_enabled, writing_enabled, all}.rayon feature.From<DynamicImage> for all image types.Bug fixes:
GifDecoder::with_limits to raise an error when limits are exceeded.New features:
{ImageBuffer, DynamicImage}::write_with_encoder to simplify writing
images with custom settings.GenericImageViewsBug fixes:
Structural changes:
tiff crate to 0.8.0.jpeg crate to 0.3.0.Bug fixes:
as_rgb32f function of DynamicImage is now correctly documented.PngEncoder::write_image
instead of the deprecated PngEncoder::encode which did not account for byte
order and could result in images with incorrect colors.InsufficientMemory error when trying to decode a PNG image.Performance:
New Features:
webp is now available with the native library. This needs to
be activate explicitly with the web-encoder feature.exr decoding has gained basic limit support.Bug fixes:
Iterator::size_hint implementation of pixel iterators has been fixed to
return the current length indicated by its ExactSizeIterator hint.Performance:
ImageBuffer::get_pixel{,_mut} is now marked inline.resize now short-circuits when image dimensions are unchanged.New Features:
TiffDecoder now supports setting resource limits.Bug fixes:
Structural changes:
cargo-deny, checking dependent crates to an OSS license list
and against RUSTSEC advisories.New Features:
VP8X header.DX10 headers.Bug fixes:
DynamicImage/ImageBuffer's methods write_to and save will now
work properly even if the backing container is larger than the image layout
requires. Only the relevant slice of pixel data is passed to the encoder.gif decoder.Bug Fixes:
Breaking changes
Structural changes:
1.56 and may change in minor versions until
further notice. It is now tracked in the library's Cargo.toml, instead, by
the standard [package.rust-version] field. Note: this applies to the
library itself. You may need different version resolutions for dependencies
when using a non-stable version of Rust.math::utils::{nq, utils} modules have been removed. These are better
served through the color_quant crate and the standard library respectively.image::codecs, no longer top-level.ExtendedColorType and DynamicImage have been made #[non_exhaustive],
providing more methods instead of exhaustive matching.io::Reader, as well as generic
convenience interfaces, now requires the underlying reader to be BufRead + Seek. This allows more efficient support more formats. Similarly, writing
now requires writers to be Write + Seek.Bgra* variants of buffers, which were only half-supported, have been
removed. The owning buffer types ImageBuffer and DynamicImage
fundamentally already make a choice in supported pixel representations. This
allows for more consistent internal behavior. Callers are expected to convert
formats when using those buffers, which they are required to do in any case
already, and which is routinely performed by decoders.Trait reworks:
Pixel trait is no longer implemented quite as liberally for structs
defined in the crate. Instead, it is now restricted to a set of known channel
which ensures accuracy in computations involving those channels.ImageDecoderExt trait has been renamed to ImageDecoderRect, according
to its actual functionality.Pixel trait and its Subpixel field no longer require (or provide) a
'static lifetime bound.Pixel trait no longer requires specifying an associated, constant
ColorType. This was of little relevance to computation but made it much
harder to implement and extend correctly. Instead, the private
PixelWithColorType extension is added for interfaces that require a
properly known variant.SubImage interacts with the GenericImage trait. It is now a
default implementation. Note that SubImage now has inherent methods that
avoid double-indirection, the trait's method will no longer avoid this.Primitive trait now requires implementations to provide a minimum and
maximum logical bound for the purpose of converting to other primitive
representations.Additions
Image formats:
jpeg decoder has been upgraded to Lossless JPEG.AvifEncoder now correctly handles alpha-less images. Some additional
color formats are converted to RGBA as well.Bmp codec now decodes more valid images. It can decode a raw image
without performing the palette mapping. It provides a method to access the
palette. The encoder provides the inverse capabilities.Tiff is now an output format.Buffers and Operations:
f32 is now supported. Currently only the
OpenEXR codec makes full use of it but this is expected to change.ImageBuffer::{get_pixel_checked, get_pixel_mut_checked} provide panic-free
access to pixels and channels by returning Option<&P> and Option<&mut P>.ImageBuffer::write_to has been added, encoding the buffer to a writer. This
method already existed on DynamicImage.DynamicImage now implements From<_> for all supported buffer types.DynamicImage now implements Default, an empty Rgba8 image.imageops::overlay now takes coordinates as i64.Limits:
Limits and LimitSupport, utilized in io::Reader. These can be
configured for rudimentary protection against resource exhaustion (images
pretending to require a very large buffer). These types are not yet
exhaustive by design, and more and stricter limits may be added in the
future.set_limits extension to ImageDecoder. Some strict limit are opt-in, which
may cause decoding to fail if not supported.Miscellaneous:
PNMSubtype has been renamed to PnmSubtype, by Rust's naming scheme.PNM* aliases have been removed.enum types that had previously used a hidden variant now use the
official #[non_exhaustive] attribute instead.Unified gif blending in different decode methods, fixing out-of-bounds checks in a number of weirdly positioned frames.
Hardened TGA decoder against a number of malicious inputs.
Fix forward incompatible usage of the panic macro.
Fix load_rect for gif reaching unreachable!() code.
Added ExtendedColorType::A8.
Allow TGA to load alpha-only images.
Optimized load_rect to avoid unnecessary seeks.
Fix an inconsistency in supported formats of different methods for encoding an image.
Fix thumbnail choosing an empty image. It now always prefer non-empty image
dimensions.
Fix integer overflow in calculating requires bytes for decoded image buffers for farbfeld, hdr, and pnm decoders. These will now error early.
Fix a panic decoding certain jpeg image without frames or meta data.
Optimized the jpeg encoder.
Optimized GenericImage::copy_from default impl in various cases.
Add avif decoders. You must enable it explicitly and it is not covered by
our usual MSRV policy of Rust 1.34. Instead, only latest stable is supported.
Add ImageFormat::{can_read, can_write}
Add Frame::buffer_mut
Add speed and quality options on avif encoder.
Add speed parameter to gif encoder.
Expose control over sequence repeat to the gif encoder.
Add {contrast,brighten,huerotate}_in_place functions in imageproc.
Relax Default impl of ImageBuffer, removing the bound on the color type.
Derive Debug, Hash, PartialEq, Eq for DynamicImage
Fix a soundness issue affecting the impls of Pixel::from_slice_mut. This
would previously reborrow the mutable input reference as a shared one but
then proceed to construct the mutable result reference from it. While UB
according to Rust's memory model, we're fairly certain that no miscompilation
can happen with the LLVM codegen in practice.
See 5cbe1e6767d11aff3f14c7ad69a06b04e8d583c7 for more details.
Fix imageops::blur panicking when sigma = 0.0. It now defaults to 1.0
as all negative values.
Fix re-exporting png::{CompressionType, FilterType} to maintain SemVer
compatibility with the 0.23 releases.
Add ImageFormat::from_extension
Add copyless DynamicImage to byte slice/vec conversion.
Add bit-depth specific into_ and to_ DynamicImage conversion methods.
NeuQuant implementation is now supplied by color_quant. Use of the
type defined by this library is discouraged.jpeg decoder can now downscale images that are decoded by 1,2,4,8.clamp function. Use num-traits instead.ImageOutputFormat for AVIFtiff to 0.6 with lzw performance improvements.ravif crate. Please note that
the feature targets the latest stable compiler and is not enabled by default.ImageBuffer::as_raw to inspect the underlying container.gif to 0.11 with large performance improvements.imageops::{vertical_gradient, horizontal_gradient} for writing
simple color gradients into an image.Pixels, PixelsMut, etc. by using exact
chunks internally. This should auto-vectorize ImageBuffer::from_pixel.Clone impls of iterators to not require a bound on the pixel.Debug impls for iterators where the pixel's channel implements it.FilterTypeflat::Error now implements the standard Error traitMap has been relaxed to ?Sizedimageops::tile function that repeats one image across anotherImageBuffer can now be clonedtga encoderColorMap::lookup, an optional reversal of the mapEncodableLayout trait is now exportedpng::ApngDecoder, an adapter decoding the animation in an APNG.jpeg encoding that would darken output colors.FlatSamples::with_monocolor.ImageBuffer::as_flat_samples_mut which is a mutable variant of the
existing ffi-helper ImageBuffer::as_flat_samples.png encoder now allows configuring compression and filter type. The
output is not part of stability guarantees, see its documentation.jpeg encoder now accepts any implementor of GenericImageView. This
allows images that are only partially present in memory to be encoded.ImageBuffer now derives Hash, PartialEq, Eq.Pixels/PixelsMut iterator no longer yields out-of-bounds pixels when
the underlying buffer is larger than required.pbm decoder correctly decodes ascii data again, fixing a regression
where it would use the sample value 1 as white instead of 255.gif frames.Rows/RowsMut iterator no longer panics when the image has
a width or height of 0.crop_imm which functions like crop but on a shared referenceDisposalMethod::Any is treated as Keep, consistent with browsersError::sourceColorType::has_alpha to facilitate lossless conversionfarbfeld formatImageBuffer methodsjpeg-decoder now reflects minimum requirements.This major release intends to improve the interface with regards to handling of color format data and errors for both decoding and encoding. This necessitated many breaking changes anyways so it was used to improve the compliance to the interface guidelines such as outstanding renaming.
It is not yet perfect with regards to color spaces but it was designed mainly as an improvement over the current interface with regards to in-memory color formats, first. We'll get to color spaces in a later major version.
ColorType:
Sized and one can crate slices of channel
values).ExtendedColorType is used to express more generic color formats for
which the library has limited support but can be converted/scaled/mapped
into a ColorType buffer. This operation might be fallible but, for
example, includes sources with 1/2/4-bit components.8-bit RGB and 16-bit BGR
are instantiations of RGB color model.ImageError:
ImageFormat have also been considered.Error::source that can be downcast to an error from a
matching version of the underlying decoders. Note that the version is not
part of the stable interface guarantees, this should not be relied upon
for correctness and only be used as an optimization.ImageDecoder trait:
read_image takes an output buffer argument instead of allocating all
memory on its own.dimensions now aligns with GenericImage sizes.colortype method was renamed to color_type for conformity.ColorType, DynamicImage, imageops::FilterType, ImageFormat
no longer re-export all of their variants in the top-level of the crate. This
removes the growing pollution in the documentation and usage. You can still
insert the equivalent statement on your own:
use image::ImageFormat::{self, *};encode operations is now uniformly an ImageResult<()>.tiff, png, gif, jpeg types,
mainly such as error conversion. This allows upgrading the dependency across
major versions without a major release in image itself.gif encoder no longer takes a
gif::Frame but rather deals with image::Frame only. If you require to
specify the disposal method, transparency, etc. then you may want to wait
with upgrading but (see next change).gif encoder now errors on invalid dimensions or unsupported color
formats. It would previously silently reinterpret bytes as RGB/RGBA.ImageFormat and other enum variants has been
adjusted to adhere to the API guidelines. These variants are now spelled
Gif, Png, etc. The same change has been made to the name of types such as
HDRDecoder.Progress type has finally received public accessor method. Strange that
no one reported them missing.PixelDensity and PixelDensityUnit to store DPI information in
formats that support encoding this form of meta data (e.g. in jpeg).GenericImage::copy_within, specialized for ImageBuffergif filesIntoIterator in example codeError::descriptionDynamicImage::into_* which convert without an additional allocation.gif with save_buffer.io containing a configurable Reader. It can replace
the bunch of free functions: image::{load_*, open, image_dimensions} while
enabling new combinations such as open but with format deduced from content
instead of file path.const_err lint in the macro expanded implementations of Pixel. This
can only affect your crate if image is used as a path dependency.unsafe trait accessors. Further evaluation showed that their
deprecation should be delayed until trait impl specialization is available.tiff images.DynamicImage::from_decoder.PNGReader that caused an infinite loop.ColorType::{bits_per_pixel, num_components}.ImageFormat::from_path, same format deduction as the open method.gif to web browser implementations.gif.lzw dependency, an indirect dependency in tiff.1.34.2.PixelMut now only on ImageBuffer and removed from GenericImage
interface. Prefer iterating manually in the generic case.ImageBuffer/DynamicImage with specified format0.3 with a writer0.15, fixes reading of interlaced sub-byte pixelsImageDecoder::Readerapply_without_alpha and map_without_alpha to Pixel traitImageDecoder trait.'static bounds on affine operationsImageBuffer, mutable variantsunsafe operations into safe alternativesImageBuffer index calculation for very, very large imagesGenericImageViewImageDecoder traitanimation::Framesto_bgra document commentGenericImage and GenericImageView is now object-safesave consistent.apply_with_alpha.TGADecoder::read_scanline.pixels_mut.#[derive(Hash)] for ColorType.num-derive for #[derive(FromPrimitive)].into_frames implementation for GIF.ExactSizeIterator implementations to buffer structs.resize_to_fill method.std::old_io with std::io.blur or invert