Module: Murlsh::ImageList

Defined in:
lib/murlsh/image_list.rb

Overview

Magick::ImageList mixin.

Constant Summary collapse

FormatExtensions =
{
  'GIF' => '.gif',
  'JPEG' => '.jpg',
  'PNG' => '.png',
}

Instance Method Summary collapse

Instance Method Details

#data_uriObject



22
# File 'lib/murlsh/image_list.rb', line 22

def data_uri; "data:#{mime_type};base64,#{Base64.encode64(to_blob)}"; end

#preferred_extensionObject

Get the preferred extension for this image.



20
# File 'lib/murlsh/image_list.rb', line 20

def preferred_extension; FormatExtensions[self.format]; end

#resize_down!(max_side) ⇒ Object

For each image, if the width or height is larger than max_side, resize so that the longest side = max_side.



10
11
12
13
14
15
16
17
# File 'lib/murlsh/image_list.rb', line 10

def resize_down!(max_side)
  each do |i|
    if i.columns > max_side or i.rows > max_side
      i.resize_to_fit! max_side, max_side
    end
    i.strip!
  end
end