* Add resize_to_cover
* Add an initial resize_to_cover test
* Fix method name and add passing tests for VIPS
* Add cover method for MiniMagick and add tests
* Rearrange VIPS tests to match source code order
* Update CHANGELOG.md
* Add documentation for cover to both engines
* Add :mode, :gravity, and :offset parameters for Vips#composite
* Replace :compose and :geometry parameters with :mode and :offset in
MiniMagick#composite
This change makes it possible to position watermarks with the libvips
implementation.
Warnings can be raised even in benign situations, like a TIFF file
having an unknown profile, which allegedly happens often. Or maybe an
image can be missing a single pixel row, which might not even be
visible. We don't want to fail on such benign cases. I've also seen no
other image processing library having this default, so I don't think we
should either.
When it comes to colors, libvips works a bit differently than
ImageMagick. With ImageMagick if you specify the alpha channel in the
background color, the alpha channel will be automatically added to the
image if it supports it (e.g. when output format is PNG).
However, in libvips you need to add the alpha channel manually if you're
converting from a format that doesn't have it (such as JPEG). Since we
don't know what will be the output format at the time of processing, we
don't know whether we should add the additional alpha channel or not,
so we make it opt-in.
When an alpha channel is added, any colors now need to be specified as
an array of 4 numbers, specifying an array with 3 numbers will raise an
exception. The vips_gravity() will by default use a background color
with all bits set to 0, which will be black when there is no alpha
channel, and transparent when there is an alpha channel.
Previous version didn't work with PNGs that have an alpha channel,
because we were always specifying background color with 3 numbers, and
PNGs with alpha channel needs 4 numbers or it will raise an exception.
Because of this reason we also needed to remove the Vips::Color module,
as it contained only RGB colors which wouldn't work with RGBA images. We
could theoretically retrieve the number of bands, and add an alpha
channel of 255 in this case, but I don't really understand what bands
are and maybe some images may have 5 or 2 bands, so I would prefer to
make as few assumptions as possible.
Vips::Image#thumbnail_image uses `vips_thumbnail()`, which has common
features for generating thumbnails, and according to the VIPS author
it has better quality and is also faster than the regular
`vips_resize()`.
This allows us to remove all the logic for calculating dimensions,
because `vips_thumbnail()` does the right thing.
This also autorotates the images on processing, which is what we'll
apply to MiniMagick as well.