Skip to content

Instantly share code, notes, and snippets.

@lchanmann
Created August 4, 2016 22:43
Show Gist options
  • Select an option

  • Save lchanmann/0ce2b8254efd7e3456aec27584fdaf4e to your computer and use it in GitHub Desktop.

Select an option

Save lchanmann/0ce2b8254efd7e3456aec27584fdaf4e to your computer and use it in GitHub Desktop.
RMagick thumbnail
require 'RMagick'
img = Magick::Image.read("photo.jpg").first
scale_factor = 20.0 / [img.rows, img.columns].max
thumbnail = img.thumbnail(scale_factor)
thumbnail.border! 1, 1, 'gray60'
thumbnail.border! 1, 1, 'red'
thumbnail.write "photo_thumbnail.jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment