-
Added support for multi-thread image processing with the help of
rayon
crate. You should enablerayon
feature to turn on this behavior. -
Added methods to split image in different directions:
ImageView::split_by_height()
ImageView::split_by_width()
ImageViewMut::split_by_height_mut()
ImageViewMut::split_by_width_mut()
These methods have default implementation and are used for multi-thread image processing.
- BREAKING: Added supertraits
Send
,Sync
andSized
to theImageView
trait. - Optimized convolution algorythm by deleting zero coefficients from start and end of bounds.
- Disabled default features of the
image
crate (#36).
-
Added new resize algorithm
ResizeAlg::Interpolation
(#32).It is like
ResizeAlg::Convolution
but with fixed kernel size. This algorithm can be useful if you want to get a result similar toOpenCV
(exceptINTER_AREA
interpolation).
- Added support for optimization with help of
SSE4.1
andAVX2
for theF32
pixel type. - Added support for new pixel types
F32x2
,F32x3
andF32x4
with optimizations forSSE4.1
andAVX2
(#30).
- Added Gaussian filter for convolution algorithm.
- Method
PixelType::size()
was made public. - Added new image containers:
ImageRef
TypedImageRef
TypedImage
TypedCroppedImage
TypedCroppedImageMut
CroppedImage
CroppedImageMut
- Fixed dividing image by alpha channel.
A lot of breaking changes have been done in this release:
- Structures
ImageView
andImageViewMut
have been removed. They always did unnecessary memory allocation to store references to image rows. Instead of these structures, theImageView
andImageViewMut
traits have been added. The crate accepts any image container that provides these traits. - Also, traits
IntoImageView
andIntoImageViewMut
have been added. They allow you to write runtime adapters to convert your particular image container into something that providesImageView
/ImageViewMut
trait. Resizer
now has two methods for resize (dynamic and typed):resize()
accepts references toimpl IntoImageView
andimpl IntoImageViewMut
;resize_typed()
accepts references toimpl ImageView
andimpl ImageViewMut
.
- Resize methods also accept the
options
argument. With the help of this argument, you can specify:- resize algorithm (default: Lanczos3);
- how to crop the source image;
- whether to multiply the source image by the alpha channel and
divide the destination image by the alpha channel.
By default, Resizer multiplies and divides by alpha channel
images with
U8x2
,U8x4
,U16x2
andU16x4
pixels.
- Argument
resize_alg
was removed fromResizer::new()
method, useoptions
argument of methods to resize instead. - The
MulDiv
implementation has been changed in the same way asResizer
. It now has two versions of each method: dynamic and typed. - Type of image dimensions has been changed from
NonZeroU32
intou32
. Now you can create and use zero-sized images. Image
(embedded implementation of image container) moved from root of the crate into moduleimages
.- Added optional feature "image".
It adds implementation of traits
IntoImageView
andIntoImageViewMut
for the DynamicImage type from theimage
crate. This implementation allows you to useDynamicImage
instances as arguments for methods of this crate.
Look at the difference between versions 3 and 4 on example of resizing RGBA8 image from given u8-buffer with pixels-data.
3.x version:
use fast_image_resize::{Image, MulDiv, PixelType, Resizer};
use std::num::NonZeroU32;
fn my_resize(
src_width: u32,
src_height: u32,
src_pixels: &mut [u8],
dst_width: u32,
dst_height: u32,
) -> Image {
let src_width = NonZeroU32::new(src_width).unwrap();
let src_height = NonZeroU32::new(src_height).unwrap();
let src_image = Image::from_slice_u8(
src_width,
src_height,
src_pixels,
PixelType::U8x4,
).unwrap();
// Multiple RGB channels of source image by alpha channel.
let alpha_mul_div = MulDiv::default();
let mut tmp_image = Image::new(
src_width,
src_height,
PixelType::U8x4,
);
alpha_mul_div
.multiply_alpha(
&src_image.view(),
&mut tmp_image.view_mut(),
).unwrap();
// Create container for data of destination image.
let dst_width = NonZeroU32::new(dst_width).unwrap();
let dst_height = NonZeroU32::new(dst_height).unwrap();
let mut dst_image = Image::new(
dst_width,
dst_height,
PixelType::U8x4,
);
// Get mutable view of destination image data.
let mut dst_view = dst_image.view_mut();
// Create Resizer instance and resize source image
// into buffer of destination image.
let mut resizer = Resizer::default();
resizer.resize(&tmp_image.view(), &mut dst_view).unwrap();
// Divide RGB channels of destination image by alpha.
alpha_mul_div.divide_alpha_inplace(&mut dst_view).unwrap();
dst_image
}
4.x version:
use fast_image_resize::images::{Image, ImageRef};
use fast_image_resize::{PixelType, Resizer};
fn my_resize(
src_width: u32,
src_height: u32,
src_pixels: &[u8],
dst_width: u32,
dst_height: u32,
) -> Image {
let src_image = ImageRef::new(
src_width,
src_height,
src_pixels,
PixelType::U8x4,
).unwrap();
// Create container for data of destination image.
let mut dst_image = Image::new(
dst_width,
dst_height,
PixelType::U8x4,
);
// Create Resizer instance and resize source image
// into buffer of destination image.
let mut resizer = Resizer::new();
// By default, Resizer multiplies and divides by alpha channel
// images with U8x2, U8x4, U16x2 and U16x4 pixels.
resizer.resize(&src_image, &mut dst_image, None).unwrap();
dst_image
}
- Fixed error with incorrect cropping of source image.
- Fixed version of
num-traits
in theCargo.toml
.
- Added
Custom
variant forFilterType
enum and correspondingFilter
structure. - BREAKING: Added a new variant of enum
CropBoxError::WidthOrHeightLessOrEqualToZero
.
- Slightly improved (about 3%) speed of
AVX2
implementation ofConvolution
trait forU8x3
andU8x4
images. - BREAKING: Changed internal data type for
U8x4
structure. Now it is[u8; 4]
instead ofu32
. - Significantly improved (4.5 times on
x86_64
) speed of vertical convolution pass implemented in native Rust forU8
,U8x2
,U8x3
andU8x4
images. - Changed order of convolution passes for
U8
,U8x2
,U8x3
andU8x4
images. Now a vertical pass is the first and a horizontal pass is the second. - BREAKING: Type of the
CropBox
fields has been changed tof64
. Now you can use fractional size and position of crop box. - BREAKING: Type of the
centering
argument ofImageView::set_crop_box_to_fit_dst_size()
andDynamicImageView::set_crop_box_to_fit_dst_size()
methods has been changed toOptional<(f64, f64)>
. - BREAKING: The
crop_box
argument ofImageViewMut::crop()
andDynamicImageViewMut::crop()
methods has been replaced with separateleft
,top
,width
andheight
arguments.
- Fixed size of rows in cropped
ImageViewMut
created byImageViewMut::crop
method (#17).
- Added using of (read|write)_unaligned for unaligned pointers
on
arm64
andwasm32
architectures. (#15).
- Added using of (read|write)_unaligned for unaligned pointers on
x86_64
architecture. (#16).
- Added method
DynamicImageViewMut::crop()
to create cropped version ofDynamicImageViewMut
(#13). - Added method
ImageViewMut::crop()
to create cropped version ofImageViewMut
.
- Slightly improved speed of
Convolution
implementation forU8x2
images andWasm32 SIMD128
instructions. - Method
Image::buffer_mut()
was made public (#14)
- Added support of optimisation with helps of
Wasm32 SIMD128
for all types of images excludeI32
andF32
(thanks to @cdmurph32, #11).
- Benchmark framework
glassbench
replaced bycriterion
. - Added report with results of benchmarks for
wasm32-wasi
target.
- Slightly improved speed of
MulDiv
implementation forU8x2
,U8x4
,U16x2
andU16x4
images. - Added optimisation for processing
U16x2
images byMulDiv
with helps ofNEON SIMD
instructions. - Excluded possibility of unnecessary operations during resize of cropped image by convolution algorithm.
- Added implementation
From
trait to convertImageViewMut
intoImageView
. - Added implementation
From
trait to convertDynamicImageViewMut
intoDynamicImageView
.
- Added support of optimisation with helps of
NEON SIMD
for convolution ofU16
images. - Added support of optimisation with helps of
NEON SIMD
for convolution ofU16x2
images. - Added support of optimisation with helps of
NEON SIMD
for convolution ofU16x3
images. - Improved optimisation of convolution with helps of
NEON SIMD
forU8
images.
- Added support of optimisation with helps of
NEON SIMD
for convolution ofU8
images. - Added support of optimisation with helps of
NEON SIMD
for convolution ofU8x2
images. - Added support of optimisation with helps of
NEON SIMD
for convolution ofU8x3
images. - Added optimisation for processing
U8x2
images byMulDiv
with helps ofNEON SIMD
instructions.
- Added method
CpuExtensions::is_supported(&self)
. - Internals of
PixelComponentMapper
changed to use heap to store its data. - Added support of optimisation with helps of
NEON SIMD
for convolution ofU16x4
images. - Added optimisation for processing
U16x4
images byMulDiv
with helps ofNEON SIMD
instructions. - Added full optimisation for convolution of
U8
images with helps ofSSE4.1
instructions. - Fixed link to documentation page in
README.md
file. - Fixed error in implementation of
MulDiv::divide_alpha()
andMulDiv::divide_alpha_inplace()
forU16x4
pixels with optimisation with helps ofSSE4.1
andAVX2
. - Improved optimisation of
MulDiv
with helps ofNEON SIMD
forU8x4
pixels.
- Breaking changes:
- Struct
ImageView
replaced by enumDynamicImageView
. - Struct
ImageViewMut
replaced by enumDynamicImageViewMut
. - Trait
Pixel
renamed intoPixelExt
and some its internals changed:- associated type
ComponentsCount
renamed intoCountOfComponents
. - associated type
ComponentCountOfValues
deleted. - associated method
components_count
renamed intocount_of_components
. - associated method
component_count_of_values
renamed intocount_of_component_values
.
- associated type
- All pixel types (
U8
,U8x2
, ...) replaced by type aliases for new generic structurePixel
. Use methodnew()
to create instance of one pixel.
- Struct
- Added structure
PixelComponentMapper
that holds tables for mapping values of pixel's components in forward and backward directions. - Added function
create_gamma_22_mapper()
to create instance ofPixelComponentMapper
that converts images with gamma 2.2 to linear colorspace and back. - Added function
create_srgb_mapper()
to create instance ofPixelComponentMapper
that converts images from SRGB colorspace to linear RGB and back. - Added generic structs
ImageView
andImageViewMut
. - Added functions
change_type_of_pixel_components
andchange_type_of_pixel_components_dyn
that change type of pixel's components in whole image. - Added generic trait
IntoPixelComponent<Out: PixelComponent>
. - Added generic structure
Pixel
for create all types of pixels. - Added full support of optimisation with helps of
SSE4.1
for convolution ofU8x3
images. - Added support of optimisation with helps of
NEON SIMD
for convolution ofU8x4
images. - Added optimisation for processing
U8x4
images byMulDiv
with helps ofNEON SIMD
instructions.
- Added option
--high_precision
to useu16
as pixel components for intermediate image representation. - Added converting of source image into linear colorspace before it will be resized. Destination image will be returned into original colorspace before it will be saved.
- Added example of command line application "resizer".
- Fixed resizing when the destination image has the same dimensions as the source image (#9).
- Added support of new type of pixels
PixelType::U16x4
. - Fixed benchmarks for resizing images with alpha channel using
the
resizer
crate. - Removed
image
crate from benchmarks for resizing images with alpha. - Added method
Image::copy(&self) -> Image<'static>
.
- Fixed README.md
- Added support of new type of pixels
PixelType::U16x2
(e.g. luma with alpha channel).
- Added support of new type of pixels
PixelType::U16
.
- Added optimisation for convolution of
U8x2
images with helps ofSSE4.1
.
- Added optimisation for processing
U8x2
images byMulDiv
with helps ofSSE4.1
andAVX2
instructions. - Added optimisation for convolution of
U16x2
images with helps ofAVX2
instructions.
- Added support of new type of pixels
PixelType::U8x2
. - Added into
MulDiv
support of images with pixel typeU8x2
. - Added method
Image::into_vec(self) -> Vec<u8>
(#7).
- Added optimisation for convolution of U16x3 images with helps of
SSE4.1
andAVX2
instructions. - Added partial optimisation for convolution of U8 images with helps of
SSE4.1
instructions. - Allowed to create an instance of
Image
,ImageVew
andImageViewMut
from a buffer larger than necessary (#5). - Breaking changes:
- Removed methods:
Image::from_vec_u32()
,Image::from_slice_u32()
. - Removed error
InvalidBufferSizeError
.
- Removed methods:
- Added support of new type of pixels
PixelType::U16x3
. - Breaking changes:
- Added variant
U16x3
into the enumPixelType
.
- Added variant
- Added optimisation of multiplying and dividing image by alpha channel with helps
of
SSE4.1
instructions. - Improved performance of dividing image by alpha channel without forced SIMD instructions.
- Breaking changes:
- Deleted variant
SSE2
from enumCpuExtensions
.
- Deleted variant
- Added optimisation of convolution U8x3 images with helps of
AVX2
instructions. - Fixed error in code for convolution U8x4 images with helps of
SSE4.1
instructions. - Fixed error in code for convolution U8 images with helps of
AVX2
instructions.
- Fixed compile errors on non-x86 architectures.
- Fixed compile errors on non-x86 architectures.
- Added support of new type of pixels
PixelType::U8x3
(with auto-vectorization for SSE4.1). - Exposed module
fast_image_resize::pixels
with typesU8x3
,U8x4
,F32
,I32
,U8
used as wrappers for represent type of one pixel of image. - Some optimisations in code of convolution written in Rust (without intrinsics for SIMD).
- Breaking changes:
- Added variant
U8x3
into the enumPixelType
. - Changed internal tuple structures inside of variant of
ImageRows
andImageRowsMut
enums.
- Added variant
- Added optimisation of convolution grayscale images (U8) with helps of
AVX2
instructions.
- Added support of new type of pixels
PixelType::U8
(without forced SIMD). - Breaking changes:
ImageData
renamed intoImage
.SrcImageView
andDstImageView
replaced byImageView
andImageViewMut
.- Method
Resizer.resize()
now returnsResult<(), DifferentTypesOfPixelsError>
.
- Added support of compilation for architectures other than x86_64.
- Added method
SrcImageView.set_crop_box_to_fit_dst_size()
. - Fixed out-of-bounds error during resize with cropping.
- Refactored
ImageData
.- Added methods:
from_vec_u32()
,from_vec_u8()
,from_slice_u32()
,from_slice_u8()
. - Removed methods:
from_buffer()
,from_pixels()
.
- Added methods:
- Fixed typo in name of CatmullRom filter type.