image_processing: Can we still use cmd blocks with the new API?

Hey, Janko. The new API looks awesome.

Quick question, tho. I’m passing in custom image magick commands via the cmd block:

resize_to_fill(image, 1024, 1024) do |cmd|
  cmd.interlace('plane')
  cmd.quality 85
  cmd.sharpen "0x1.0"
end

How can I do this with the new API?

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Okay, here’s a working version of a carrier-wave-style sharpen mask:

mask = Vips::Image.new_from_array [
       [-1, -1, -1],
       [-1, 24, -1],
       [-1, -1, -1]], 16

ImageProcessing::Vips
  .source(image)
  .resize_to_fit(1024, 1024)
  .saver(Q: quality, interlace: true)
  .conv(mask)
  .call

I don’t really understanding the image mask values, but these settings produce a nice, subtle sharpening effect on resized images.

Here’s a Wikipedia page on how these masks work in the abstract: https://en.wikipedia.org/wiki/Kernel_(image_processing)

One tweak to my earlier suggestion: we should only enable sharpening for JPEGs by default. 😃

Sharpening PNGs and GIFs may dramatically increase file sizes – since these are lossless formats sharpening adds more information to images and that means bigger files.