Skip to content

Instantly share code, notes, and snippets.

@jcupitt
Last active April 30, 2023 02:32
Show Gist options
  • Save jcupitt/8939150 to your computer and use it in GitHub Desktop.
Save jcupitt/8939150 to your computer and use it in GitHub Desktop.
auto-crop in ruby-vips
#!/usr/bin/env ruby
# "trim" is nnow built in, so this is easy
require 'vips'
im = Vips::Image.new_from_file(ARGV[0])
left, top, width, height = im.find_trim
im = im.crop(left, top, width, height)
im.write_to_file(ARGV[1])
@danielb2
Copy link

danielb2 commented Apr 30, 2023

thank you. hm. seems background: 0 did it. but the filesize is bigger after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment