45 Commits

Author SHA1 Message Date
Janko Marohnić 9d72e46bce Support resize-on-load for resize to cover
We can now rename it back to `#resize_to_cover`, since vips backend
requires all `resize_to_*` operations to support resize-on-load.
2024-06-15 23:10:03 +02:00
Janko Marohnić c2a9a73044 Remove non-existing #append Vips API
Closes #122
2024-06-10 14:53:27 +02:00
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ć 7cd4058e14 [minimagick] Add #crop with left, top, width, height arguments
This allows us to replace

  crop("300x300+0+50")

with

  crop(0, 50, 300, 300)

This matches the existing libvips' vips_crop() arguments.
2020-05-17 09:30:25 +02:00
Janko Marohnić 9fb6a0b9ee Add table of contents 2019-12-10 13:49:50 +01:00
Janko Marohnić 4927d40c83 [vips] Allow forcing a specific loader or saver
Sometimes libvips is not able to identify the source image type, even if
there is a corresponding loader. In this case it's useful to be able to
tell libvips which loader to use. So, we add a `:loader` option that
does just that:

  ImageProcessing::Vips
    .loader(loader: :svg) # calls `Vips::Image.svgload`
    # ...

For symmetry, we also add a `:saver` option, just in case libvips isn't
able to correctly identify the file extension of the destination path.

  ImageProcessing::Vips
    .saver(saver: :tiff) # calls `Vips::Image#tiffsave`
    # ...

Closes #49
2019-04-09 01:07:31 +02:00
Janko Marohnić 4880c27bff [vips] Simplify resize-on-load logic a bit 2019-02-25 11:04:06 +01:00
Janko Marohnić 3c9c0922b8 [vips] Perform resize-on-load when possible
Resizing on load using `vips_thumbnail()` (versus after load using
`vips_thumbnail_image()`) can speed up resizing significantly, and in
some cases even make it more accurate.

  thumbnail_image() (1000px => 300px) – 0.062s
  thumbnail()       (1000px => 300px) – 0.031s

  thumbnail_image() (1000px => 500px) – 0.045s
  thumbnail()       (1000px => 500px) – 0.043s

  thumbnail_image() (1000px => 800px) – 0.046s
  thumbnail()       (1000px => 800px) – 0.043s

  thumbnail_image() (1500px => 300px) – 0.104s
  thumbnail()       (1500px => 300px) – 0.037s

  thumbnail_image() (1500px => 500px) – 0.096s
  thumbnail()       (1500px => 500px) – 0.068s

  thumbnail_image() (1500px => 800px) – 0.090s
  thumbnail()       (1500px => 800px) – 0.066s

  thumbnail_image() (2000px => 300px) – 0.154s
  thumbnail()       (2000px => 300px) – 0.041s

  thumbnail_image() (2000px => 500px) – 0.170s
  thumbnail()       (2000px => 500px) – 0.051s

  thumbnail_image() (2000px => 800px) – 0.147s
  thumbnail()       (2000px => 800px) – 0.093s

  thumbnail_image() (2500px => 300px) – 0.219s
  thumbnail()       (2500px => 300px) – 0.046s

  thumbnail_image() (2500px => 500px) – 0.218s
  thumbnail()       (2500px => 500px) – 0.053s

  thumbnail_image() (2500px => 800px) – 0.215s
  thumbnail()       (2500px => 800px) – 0.123s

  thumbnail_image() (3000px => 300px) – 0.300s
  thumbnail()       (3000px => 300px) – 0.046s

  thumbnail_image() (3000px => 500px) – 0.310s
  thumbnail()       (3000px => 500px) – 0.076s

  thumbnail_image() (3000px => 800px) – 0.302s
  thumbnail()       (3000px => 800px) – 0.146s

Closes #48
2019-02-25 10:45:47 +01:00
Janko Marohnić 2e55d7bb4c [vips] Add link to emulating :low & :high crop behaviour 2019-02-11 20:50:06 +01:00
Thomas Menelle 71bb90aabc list libvips 8.8 thumbnail new crop options inside vips readme 2019-02-10 16:17:51 +01:00
Janko Marohnić 48bc840247 Update libvips GH links to point to the new org 2018-09-27 01:12:55 +02:00
Janko Marohnić 41c3198c6d Update libvips links with the new location 2018-09-27 01:11:44 +02:00
Janko Marohnić fcdc623791 [vips] Make #remove chainable
Vips::Image#remove removes metadata from a Vips::Image, which can be
useful for reducing filesize of an image or stripping potentially
sensitive data.

Like Vips::Image#set, it isn't chainable by default because the method
doesn't return a Vips::Image instance. Like #set, this commit makes
`#remove` chainable as well.
2018-09-27 01:08:59 +02:00
Janko Marohnić 9c49461621 Add note that libvips 8.7+ supports saving GIFs
libvips 8.7 added magicksave, which saves the image using ImageMagick,
and ImageMagick can save GIFs. So, as long as libvips 8.7+ is install
and compiled with ImageMagick support, saving GIFs will automatically
work.
2018-09-20 03:59:41 +02:00
Janko Marohnić b8ef94fd03 [vips] Make #rotate always call vips_similarity()
This was recommended by the libvips author in
https://github.com/jcupitt/libvips/issues/1095.

Also, since `vips_rotate()` was added to libvips 8.7 as a convenience
alias for `vips_similarity()` and we wouldn't want to break it, we
forward all additional options to `vips_similarity()`, like
`vips_rotate()` probably does.
2018-09-20 03:21:07 +02:00
Janko Marohnić eb26b8b9c7 Use same :mode and :gravity parameters 2018-07-13 14:08:10 +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ć e15b47dd43 [minimagick, vips] Add #composite method
On MiniMagick this wraps the -composite operator along with its
parameters. On libvips this provides a thin wrapper around
Vips::Image#composite.

Closes #35
2018-07-10 01:07:52 +02:00
Janko Marohnić 095d950851 [minimagick, vips] Add #rotate function (#42) 2018-06-13 11:02:53 +02:00
Janko Marohnić 2a65fccd8a Documentation fixes and improvements 2018-04-18 16:55:59 +02:00
Janko Marohnić 922c5bc8b7 [core] Extend #apply to accept any builder commands
Previously only operations were allowed in #apply. This commit extends
it to accept any builder commands, which includes :convert, :loader,
:saver etc. This will be useful for Active Storage, as it will allow
users to add conversion, loader and saver options to their on-the-fly
transformations.

This change also allows values given to #apply to be Hashes, which
previously wasn't possible in case someone wanted to use it for a
certain libvips operation.

This also brings back MiniMagick's support for "+" operators, which we
now document as well.
2018-04-18 16:55:59 +02:00
Janko Marohnić 25d1b86bdc [core] Add #apply for applying a list of operations
Both CarrierWave and ActiveStorage give the ability for the user to
provide a hash of operations that should be applied. Since the plan is
to make CarrierWave and ActiveStorage depend on ImageProcessing, I think
it's nice for ImageProcessing to provide this functionality out of the
box.

In addition to the hash of operations, we make sure we accept an array
of operations as well, so that users can repeat the same operation
multiple times.

This removes the ability for ImageProcessing::MiniMagick to accept
"false" for "+" operators in loader/saver options, but this wasn't
documented anyway. If this feature is requested, we'll find another way.
2018-04-05 17:25:52 +02:00
Janko Marohnić 565a6ce21c Show basic usage examples in module documentations 2018-04-04 21:50:27 +02:00
Janko Marohnić 3a69a23d43 Upcase notes 2018-04-04 21:46:28 +02:00
Janko Marohnić beeea21df9 Some final README tweaks
* include link to libvips benchmarks
* remove trailing whitespace
* change installation instructions to use multi-line code blocks
* remove upfront notices about automatic rotation and sharpening
2018-04-04 21:30:29 +02:00