Created
August 19, 2012 17:53
-
-
Save suwa320/3396720 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # -*- 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