example/daltonize8.rb in vips-8.11.3 vs example/daltonize8.rb in vips-8.12.1

- old
+ new

@@ -5,11 +5,11 @@ # http://scien.stanford.edu/pages/labsite/2005/psych221/projects/05/ofidaner/colorblindness_project.htm # see # http://libvips.blogspot.co.uk/2013/05/daltonize-in-ruby-vips-carrierwave-and.html # for a discussion of this code -require 'vips' +require "vips" # Vips.set_debug true # matrices to convert D65 XYZ to and from bradford cone space xyz_to_brad = [ @@ -27,17 +27,17 @@ # remove any alpha channel before processing alpha = nil if im.bands == 4 alpha = im[3] - im = im.extract_band 0, :n => 3 + im = im.extract_band 0, n: 3 end begin # import to XYZ with lcms # if there's no profile there, we'll fall back to the thing below - xyz = im.icc_import :embedded => true, :pcs => :xyz + xyz = im.icc_import embedded: true, pcs: :xyz rescue Vips::Error # nope .. use the built-in converter instead xyz = im.colourspace :xyz end @@ -59,12 +59,12 @@ # so this is the colour error err = im - rgb # add the error back to other channels to make a compensated image -im = im + err.recomb([[0, 0, 0], - [0.7, 1, 0], - [0.7, 0, 1]]) +im += err.recomb([[0, 0, 0], + [0.7, 1, 0], + [0.7, 0, 1]]) # reattach any alpha we saved above if alpha im = im.bandjoin(alpha) end