Sha256: 9aba8ffae87a9980152506506384843f419b076a8ddeff291c9b8ac508a389b6

Contents?: true

Size: 717 Bytes

Versions: 10

Compression:

Stored size: 717 Bytes

Contents

#!/usr/bin/env 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

10 entries across 10 versions & 2 rubygems

Version Path
vips-8.6.3.2 example/thumb.rb
vips-8.7.0.1 example/thumb.rb
ruby-vips-2.0.13 example/thumb.rb
vips-8.6.3.1 example/thumb.rb
vips-8.6.3 example/thumb.rb
ruby-vips-2.0.12 example/thumb.rb
ruby-vips-2.0.11 example/thumb.rb
ruby-vips-2.0.10 example/thumb.rb
ruby-vips-2.0.9 example/thumb.rb
ruby-vips-2.0.8 example/thumb.rb