225 Commits

Author SHA1 Message Date
Janko Marohnić 56a839ed53 Bump to 1.13.0 2024-07-24 18:54:09 +02:00
Janko Marohnić 4cc044087e Revert "Don't allow calling Kernel methods via loader/saver options"
It doesn't fully resolve the security vulnerability, and there is no
point in only partially resolving it.

See https://github.com/janko/image_processing/issues/100

This reverts commit aed5b80cd7.
2024-07-24 18:48:04 +02:00
Janko Marohnić 84e5b61fcc Still support -append in MiniMagick 2024-06-15 23:19:48 +02:00
Janko Marohnić 619c791bc7 Avoid attempting to call non-existing rot0 operation 2024-06-15 23:13:37 +02:00
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
Andrew Stevenson 02c3cc4d05 use rot command where possible (#118) 2024-06-06 12:25:08 +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ć aed5b80cd7 Don't allow calling Kernel methods via loader/saver options 2022-07-31 16:48:01 +02:00
Janko Marohnić 12e7cf50b5 Bump to 1.12.2 2022-03-01 22:15:04 +01:00
Janko Marohnić 038e4574e8 Prevent remote shell execution in #apply
If the operations are coming from user input, this could allow the user
to execute arbitrary shell commands via `Kernel#system` and
`Kernel#spawn`:

  ImageProcessing::Vips.apply({ system: "echo something" })

We prevent this by using `#public_send` instead of `#send`, which goes
to method missing instead of calling private methods, which include
`Kernel#system` and `Kernel#spawn`.
2022-03-01 22:15:04 +01:00
Janko Marohnić 0d0d9a41ee Move from Travis CI to GitHub CI (#93)
* Move from Travis CI to GitHub CI

* Update error message

* Fix Ruby 2.3 compatibility
2021-09-12 21:42:53 +02:00
Janko Marohnić bd2f8263ed Bump to 1.12.1 2020-11-06 16:14:01 +01:00
Bastian Bartmann 3db009a68b Fix format fallback for files ending in with a dot (#73)
File.extname was updated in ruby 2.7 to return “.” when the file ends in a dot. Previously it was returning an empty string. This can break determining the destination format.
2020-11-06 16:11:11 +01:00
Janko Marohnić 61d1ad6354 Bump to 1.12.0 2020-09-20 21:38:29 +02:00
Janko Marohnić 04227125bd Add instrumentation support
Closes #70
2020-09-20 21:19:50 +02:00
Janko Marohnić e8bef4dcdb Make #method_missing private, refactor #branch 2020-09-20 21:19:18 +02:00
Janko Marohnić 50e9f03c63 Bump to 1.11.0 2020-05-17 10:03:31 +02:00
Janko Marohnić fb52ea0611 [minimagick] Handle destination path without file extension
Closes #66
2020-05-17 10:02:23 +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
Florian Frank 9a9c906cde Disable sharpening with mini magick by default (#67)
The sharpening causes visible rough edges to appear in resized jpeg
images.
2020-05-17 09:29:29 +02:00
Janko Marohnić 69a87a995f Bump to 1.10.3 2020-01-12 20:47:46 +01:00
Janko Marohnić 5052cc5526 [vips] Fix auto-rotation bug on libvips 8.9.0
When performing resizing with loader options, the following gets called
internally:

  Vips::Image.new_from_file("/path/to/source.jpg")
    .autorot
    .thumbnail_image(400, 400)
    .write_to_file("/path/to/destination.jpg")

Prior to libvips 8.9.0, this code would produce a correctly auto-rotated
image. However, in libvips 8.9.0, the auto-rotation from `autorot` and
the default auto-rotation performed by `thumbnail_image` cancel each
other out, leaving the image rotated.

We fix this by disabling auto-rotation for the `thumbnail` operation, so
that the only auto-rotation done is by `autorot`. In the resize-on-load
case we leave `thumbnail` to auto-rotate, as in that case `autorot` is
not called beforehand.

Closes #64
2020-01-12 20:40:36 +01:00
Janko Marohnić aac882c309 Bump to 1.10.2 2020-01-11 15:56:35 +01:00
Ryuta Kamizono 59ce62b703 Fix Ruby 2.7 warnings (#63)
Ruby 2.7 introduced warnings around implicit conversions between
kwargs and hashes, so we fix the warnings.

If we have the following method:

  def foo(a, b, **c)
  end

And we pass arguments like this:

  args = [1, 2, { x: :y }]

  foo(*args)

This will trigger a kwarg warning on Ruby 2.7. So, we need to explicitly
pass the last argument as kwargs if it is a hash.

Surprisingly, the warning was only triggered when using #apply:

  # would trigger the kwargs warning
  ImageProcessing::Vips
    .source("/path/to/image")
    .apply!(resize_to_limit: [400, 400, sharpen: false])

And not when calling operation directly:

  # wouldn't trigger the kwargs warning
  ImageProcessing::Vips
    .source("/path/to/image")
    .resize_to_limit!(400, 400, sharpen: false)

Even though final options are exactly the same, so the code that's then
executed on processing should be the same.

  options1 = ImageProcessing::Vips
    .apply(resize_to_limit: [400, 400, sharpen: false])

  options2 = ImageProcessing::Vips
    .resize_to_limit(400, 400, sharpen: false)

  options1 == options2 #=> true

The warning was coming from Processor.apply_operation when we would call
an underlying macro. It's probably a bug in Ruby, both examples should have
triggered the same warning. But I couldn't isolate it, so instead we
add an additional test case for #apply.

Co-authored-by: Janko Marohnić <janko.marohnic@gmail.com>
2020-01-11 15:54:11 +01:00
Janko Marohnić 799ae22185 Bump to 1.10.1 2020-01-07 16:46:56 +01:00