In this article, I would like to show a sample code to generate square thumbnail image by using Minimagick
which is a Ruby wrapper for ImageMagic.
🐞 Installation
Add the gem to your Gemfile & run bundle install
:
gem 'mini_magick' |
😼 Ruby Code
In a sample source, I will show you following flow:
- (1) Download Sample Image
- (2) Cut out a square thumbnail image by using Minimagick
- (3) Save Image to file
require 'open-uri' |
So, it is operation confirmation.
The above image(640x480) was converted to the following square image(300x300):
Happy Hacking!
😸 API Document
Documentation for minimagick/minimagick
🎃 Special Thanks
- http://qiita.com/9m/i..
- http://blog.amacou.net/pos…
- https://github.com/minimagick/minimagick/issues/104
🖥 Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!