-
-
Save greenbigfrog/9bfafdac57a1dbc650507011da900732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "gobject" | |
require_gobject "Vips" | |
class Vips::Image | |
def self.new_from_file(path : String) | |
Vips::Image.new_from_file_rw(path) | |
end | |
# https://www.rubydoc.info/gems/ruby-vips/Vips/Image#cast-instance_method | |
def vips_cast(format) | |
LibVips.vips_cast(self, out casted, format) | |
Vips::Image.new(casted) | |
end | |
end | |
lib LibVips | |
alias Img = LibVips::Image | |
# https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-cast | |
fun vips_cast(input : Img*, output : Img**, band : Int32) | |
end | |
puts "Reading image" | |
img = Vips::Image.new_from_file("/home/frog/dhash-cr/test.jpg") | |
puts "Read img with width #{img.width} and height #{img.height}" | |
img.vips_cast(Vips::BandFormat::INT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment