We, the image-rs group, are glad to announce the release of a new version of
the central image
library. This is especially noteworthy since it resolves
some long standing interface issues, removes some old deprecated items and
marks some new ones, and finally contains a plethora of improvement to the set
of image decoders and encoders.
Notable changes
We have updated the compiler requirements to Rust 1.34.2
(from 1.24.1
),
together with the Debian stable release Buster. This gives us the freedom to
choose the Rust edition, many std
library improvements and basic const fn
1.
We will try to keep versions stable for as long as possible but may bump the
required version in a SemVer breaking release. Overall, you should view this as
a best effort and not an absolute guarantee.
A general rework of the ImageDecoder
trait. All decoders now have their own
reader types which allows greater flexibility for the future. These were
intended to offer an std::io::Read
interface only. If this leads to
performance pessimissations it would be possible to introduce dedicated methods
for concrete decoders.
Multiple unsafe
interfaces have been retired. The (largely) broken generic
PixelsMut
iterator of GenericImage
has been removed after its deprecation
some versions ago. Note that the specialized version on ImageBuffer
is still
available and an even more diverse set of iterators has been added for it, e.g.
RowsMut
.
A new method save_with_formats
on ImageBuffer
and DynamicImage
is now
available to make saving images easier. Encode other GenericImage
implementors by cloning their content into an ImageBuffer
first. The
supported formats are currently only jpeg
, png
, ico
, bmp
and tiff
but
that list will expand in the future.
Colors as now tuple types. This had ergonomic problems in a rather ancient version of Rust. As a style help, remember that you can match tuples and slices exhaustively on the left-hand side of an assignment, like so:
let Rgb([r, g, b]) = image.get_pixel(10, 10);
The overlay
and replace
operations no longer require both image types to be
the same but only their pixels. These changes are complementary to an update to
the GenericImage::copy_from
method, which previously returned a bool
to
indicate success. This could silently fail to do anything.
The png
library has been updated and now handles interlacing of sub-byte
pixel formats correctly.
Future changes
There are already important plans for the next version. The ecosystem is slowly
moving towards edition 2018, which is now the default for new projects, and
many improvements on quality of life but also semantic clarity are dearly
missed once one has gotten used to them. We intend to make use of our
bumped compiler version to modernize code and add interoperability where
useful. Spotted a missing and useful TryFrom
? Give us a PR and we’re happy to
discuss.
In an effort to remove even more unsafety
from the library there are also
some newly depreated methods on top of some previously deprated parts that were
removed. These will stay until we have figured out the best solution to replace
their current functionality and/or performance.
-
Also
TryFrom
for integer conversion, improvements for reference matching, nested imports, basicconst
functions, endianess conversion on integers types,#[repr(transparent)]
, more incore
,impl Trait
returns and many many more. ↩