Skip to content
Snippets Groups Projects
Commit 3d07408d authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

adding new generator


Signed-off-by: default avatarman13 <man13@inf.ufpr.br>
parent ad3d0b60
No related branches found
No related tags found
No related merge requests found
module Thumbnail
module Strategies
class PdfThumbnailGenerator < ::Thumbnail::GeneratableStrategy
def generate(media)
pdf = first_page(media.path)
hash = SecureRandom.hex(10)
output = "/tmp/#{hash}.png"
pdf.write(output)
File.open output
end
def can_generate?(media)
MimeMagic.by_magic(media).type.include? "pdf"
end
private
def first_page(pdf_path)
first_page_path = pdf_path + "[0]"
Magick::Image.read(first_page_path).first
end
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment