Skip to content

Instantly share code, notes, and snippets.

@janko
Last active December 14, 2022 09:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janko/c539732abac966693398e216eb90651b to your computer and use it in GitHub Desktop.
Save janko/c539732abac966693398e216eb90651b to your computer and use it in GitHub Desktop.
MiniMagick vs libvips benchmark (generating a 500x500 thumbnail)
width, imagemagick, libvips
1000, 0.129, 0.045
1500, 0.190, 0.067
2000, 0.276, 0.054
2500, 0.380, 0.068
3000, 0.498, 0.085
require "bundler/inline"
gemfile do
gem "image_processing"
gem "down"
gem "benchmark-ips"
end
require "image_processing/mini_magick" # imagemagick 7.0.8-59
require "image_processing/vips" # vips 8.8.1
require "down"
require "benchmark/ips"
require "csv"
# disable cache
Vips.vips_cache_set_max 0
csv = CSV.new(STDOUT)
csv << ["width", "imagemagick", "libvips"]
1000.step(by: 500, to: 3000) do |source_width|
source = Down.download("https://images.unsplash.com/photo-1549221838-126dc3ebf29f?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&w=#{source_width}")
result = Benchmark.ips(quiet: true) do |x|
x.report("imagemagick (#{source_width}px)") do
ImageProcessing::MiniMagick
.source(source)
.resize_to_limit!(500, 500)
end
x.report("libvips (#{source_width}px)") do
ImageProcessing::Vips
.source(source)
.resize_to_limit!(500, 500)
end
end
imagemagick_duration = 1 / result.data.first.fetch(:ips)
libvips_duration = 1 / result.data.last.fetch(:ips)
csv << [source_width, "%.3f" % imagemagick_duration, "%.3f" % libvips_duration]
end
@fffx
Copy link

fffx commented Jun 23, 2022

In bundle 2.3.16

[DEPRECATED] This Gemfile does not include an explicit global source. Not using an explicit global source may result in a different lockfile being generated depending on the gems you have installed locally before bundler is run. Instead, define a global source in your Gemfile like this: source "https://rubygems.org".

Need to add

source "https://rubygems.org".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment