Skip to content

Instantly share code, notes, and snippets.

@suwa320
Created August 19, 2012 17:53
Show Gist options
  • Select an option

  • Save suwa320/3396720 to your computer and use it in GitHub Desktop.

Select an option

Save suwa320/3396720 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# referred to
# http://thesteve.org/technoblarg/2011/10/01/square-thumbnails-with-minimagick/
require 'mini_magick'
module MiniMagick
class Image
def self.square(src, dst, size)
thumb = open src
thumb.square dst, size
end
def square(dst, size = 100)
combine_options do |c|
c.auto_orient
c.thumbnail "x#{size*2}"
c.resize "#{size*2}x<"
c.resize "50%"
c.gravity "center"
c.crop "#{size}x#{size}+0+0"
c.quality "92"
end
write(dst)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment