Replies: 1 comment 2 replies
-
This would probably better asked at libvips discussions. The maintainer is very responsive, and he's also the maintainer of ruby-vips, so as long as you provide the equivalent processing code using this library directly (instead of ImageProcessing), I'm sure he'll be able to give you some pointers. I believe your code translates to: require "vips"
require "tempfile"
SHARPEN_MASK = ::Vips::Image.new_from_array [[-1, -1, -1],
[-1, 32, -1],
[-1, -1, -1]], 24
output = Tempfile.new ["result", ".webp"]
Vips::Image.new_from_file(file.path)
.autorot
.thumbnail_image(target_width, height: target_height, no_rotate: true)
.conv(SHARPEN_MASK, precision: :integer)
.crop(0, 0, width.to_i, height.to_i)
.write_to_file(output.path, quality: 100) Alternatively, you could try disabling ImageProcessing's default sharpening, maybe it's making the output worse: .resize_to_limit(target_width, target_height, sharpen: false) Or maybe try enabling lossless compression instead of setting quality: .saver(lossless: true) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there!
I'm currently trying to convert a fairly large image into a thumbnail.
The original image dimensions are [2880, 16446]
The target output sizes are roughly [359, 330] (I know it's a large difference!)
Here's the code for it:
When converting to thumbnail, the image looks really pixelated
Is there any way to resize and crop it without losing it's clarity?
Edit:
Appreciate any help here! 🙏
Beta Was this translation helpful? Give feedback.
All reactions