14 Commits

Author SHA1 Message Date
Brendon Muir 8c85ad9252 Add resize_to_cover (#120)
* 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
2024-06-06 12:02:29 +02:00
Janko Marohnić f24c6d683e [minimagick, vips] Normalize #composite interface
* 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.
2018-07-13 13:57:52 +02:00
Janko Marohnić de770c9ed6 [vips, minimagick] Improve docs and tests for .valid_image? 2018-04-03 11:12:00 +02:00
Janko Marohnić c0f8e49aac [vips, minimagick] Don't fail on warnings when loading the image
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.
2018-04-03 10:59:24 +02:00
Janko Marohnić 7fac51c08e [Vips] Preserve transparent background in #resize_and_pad
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.
2018-03-21 11:16:18 +01:00
Janko Marohnić 5f9b2ad191 Delete unused fixture images 2018-03-20 21:30:37 +01:00
Janko Marohnić 63ad5b6de6 Delete unused fixture image 2018-03-12 15:09:19 +01:00
Janko Marohnić 230330c5ac Use Vips::Image#thumbnail_image
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.
2018-03-11 20:38:01 +01:00
GustavoCaso 787572f80e Added crop 2017-09-20 08:51:28 +02:00
Janko Marohnić 69fde6dd28 Add #corrupted? 2016-07-11 19:45:10 +08:00
Paul Götze d0a4b85637 Add crop 2016-05-03 18:31:10 +08:00
Paul Scarrone a2ddc803e2 Add #resample for changing resolution 2015-10-03 21:24:32 +02:00
Janko Marohnić 782caa419c Make some fixes to padding
Just porting the last commit from refile-mini_magick.
2015-10-03 21:03:25 +02:00
Janko Marohnić 8c11868932 Initial commit 2015-10-03 20:36:13 +02:00