Optimizing Image Cropping and Writing Performance with Ruby Vips #406
Unanswered
JohnAnon9771
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Hi @JohnAnon9771,
img = Vips::Image.new_from_file(image_path)
bbox = img[3].find_trim
img.crop(*bbox).write_to_file("x.png") How large are these files? PNG is a very slow format, so if the images are large, write will take a long time. Are there any other formats you could use? webp or tiff would probably be quicker. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I’m working on a project that uses Ruby Vips to crop and adjust images for printing. However, I’ve encountered performance issues, specifically with the speed of writing the cropped image to a file. The writing process is quite slow, and I’d like to know how I can optimize this further to speed up the entire operation, as I need to transmit the processed image as quickly as possible.
Here’s the relevant code I’m using for cropping the image:
The trimming works fine, but the file writing step (
write_to_file
) takes a significant amount of time. Do you have any suggestions for speeding up the writing process or improving overall performance? Any insights would be greatly appreciated!Thank you!
Beta Was this translation helpful? Give feedback.
All reactions