Skip to content

Instantly share code, notes, and snippets.

@greenbigfrog
Created May 30, 2021 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenbigfrog/5f616f7a94862e4679ea39f076743da0 to your computer and use it in GitHub Desktop.
Save greenbigfrog/5f616f7a94862e4679ea39f076743da0 to your computer and use it in GitHub Desktop.
require "gobject"
require_gobject "Vips"
def new_from_file(path : String) : Vips::Image
img = Vips::Image.new_from_file_rw(path)
end
def write_to_file(img : Vips::Image, filename : String)
LibVips.vips_image_write_to_file(img, filename)
end
lib LibVips
# https://libvips.github.io/libvips/API/current/VipsImage.html#vips-image-write-to-file
fun vips_image_write_to_file(image : LibVips::Image*, name : LibC::Char*)
end
puts "Reading image"
img = new_from_file("/home/frog/dhash-cr/test.jpg")
pp img
puts "Read img with width #{img.width} and height #{img.height}"
write_to_file(img, "out.jpg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment