Sha256: c610dcede7628a24005a67bd697be4450ed4da5d795b17448aa5483305156501
Contents?: true
Size: 550 Bytes
Versions: 16
Compression:
Stored size: 550 Bytes
Contents
# frozen_string_literal: true module DocumentExporter class Thumbnail THUMBNAIL_RATIO = 1.25 def initialize(content) @content = content end def export pdf = ::MiniMagick::Image.read(@content) @width = pdf.pages[0][:width] / THUMBNAIL_RATIO @height = pdf.pages[0][:height] / THUMBNAIL_RATIO pdf.format('jpg', 0, density: 300, background: '#fff', alpha: 'remove', resize: "#{@width}x#{@height}").to_blob end def orientation @width < @height ? 'portrait' : 'landscape' end end end
Version data entries
16 entries across 16 versions & 1 rubygems