-
-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Libvips is slower and consumes more memory than ImageMagick when resize small image #3654
Comments
So for 100 images, vipsthumbnail is 0.012s per image. You can reduce the startup time by configuring libvips without modules, and by linking it statically. You'd need to build your own binary for that though. |
@jcupitt I actually use pyvips to run Libvips. Is there a way I can decrease the time using pyvips?
Also I tried your way to test 100 images, below is the best result I got (run 10 times), is there anything I missed? Your memory is also less than my test.
|
You can use
Did you build libvips yourself? What commands did you use to build it? What host OS are you using? Is it arch? |
Want to make sure I understand what you said Did you build libvips yourself? What commands did you use to build it? What host OS are you using? Is it arch? |
So that's just startup and shutdown time, no images are processed. With pyvips, you pay that cost once when you |
You can use multiprocessing like this: #!/usr/bin/python3
import sys
import pyvips
from multiprocessing import Pool
def thumbnail(params):
filename, N = params
try:
# 58s
thumb = pyvips.Image.thumbnail(filename, 1600)
thumb.write_to_file(f"t-{N}-1600.jpg")
thumb = pyvips.Image.thumbnail(filename, 720)
thumb.write_to_file(f"t-{N}-720.jpg")
thumb = pyvips.Image.thumbnail(filename, 120)
thumb.write_to_file(f"t-{N}-120.jpg")
return 'OK'
except Exception as e:
return e
pool = Pool(8)
results = pool.map(thumbnail, zip(sys.argv[1:] ,range((len(sys.argv[1:]))))) That'll run up to 8 thumbnails at once. |
I see you talked about 4 core machine, we are using 2 core machine, will you recommend to use 4 core machine? |
You can use any number of cores you like, it was just an example. |
I think we're done, I'll close. |
I just noticed, you pasted this pyvips code: def perform_resize(image, width, height):
return image.thumbnail_image(width, height=height, size="force") Don't use
Plain It would be best to make a complete, runnable benchmark, and then tune that. If you post the exact code you are testing, I can check it for you. |
Hi Libvips team, I plan to move from ImageMagick to Libvips, but I have noticed that Libvips is slower and consumes more memory than ImageMagick when resize small image, I tried 144kb, 500kb, 1mb, 5mb, and 10mb, they all need less time and less memory than ImageMagick except 144kb and 500kb.
The commands I use
Maybe there are some configurations I missed? I wish Libvips consumes the similar time and memory as ImageMagick, is it possible?
500kb:
144kb:
The text was updated successfully, but these errors were encountered: