Sha256: 289c7fa3e89fb30904b2ef47a11603779d67bb32e4ff546dd1868588baa933cb

Contents?: true

Size: 695 Bytes

Versions: 12

Compression:

Stored size: 695 Bytes

Contents

#!/usr/bin/ruby

# batch-process a lot of files
#
# this should run in constant memory -- if it doesn't, something has broken

require "vips"

# benchmark thumbnail via a memory buffer
def via_memory(filename, thumbnail_width)
  data = IO.binread(filename)

  thumb = Vips::Image.thumbnail_buffer data, thumbnail_width, crop: "centre"

  thumb.write_to_buffer ".jpg"
end

# benchmark thumbnail via files
def via_files(filename, thumbnail_width)
  thumb = Vips::Image.thumbnail filename, thumbnail_width, crop: "centre"

  thumb.write_to_buffer ".jpg"
end

ARGV.each do |filename|
  puts "processing #{filename} ..."
  _thumb = via_memory(filename, 500)
  # _thumb = via_files(filename, 500)
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/ruby-vips-2.2.1/example/thumb.rb
ruby-vips-2.2.2 example/thumb.rb
ruby-vips-2.2.1 example/thumb.rb
vips-8.15.1 example/thumb.rb
ruby-vips-2.2.0 example/thumb.rb
vips-8.12.2 example/thumb.rb
vips-8.12.1 example/thumb.rb
ruby-vips-2.1.4 example/thumb.rb
ruby-vips-2.1.3 example/thumb.rb
ruby-vips-2.1.2 example/thumb.rb
ruby-vips-2.1.1 example/thumb.rb
ruby-vips-2.1.0 example/thumb.rb