Mini Magick で画像の任意の枠を切り抜き
(ruby version: 2.2.2p95)
sudo apt-get install imagemagick
gem install bundler
bundle init
echo "gem 'mini_magick'" >> Gemfile
bundle
require 'bundler'
Bundler.require
def crop(image, w_offset, h_offset, w, h)
# image.crop('104x193+98+95')
image.crop("#{w_offset}x#{h_offset}+#{w}+#{h}")
image
end
image = MiniMagick::Image.open(File.expand_path('./sample.jpg'))
crop(image, 104, 193, 98, 95).write(File.expand_path('./sample_cropped.jpg'))