class Paperclip::PdfCoverProcessor
This is a Paperclip::Processor that can be used to generate an image from a PDF file. The image is only of the first page.
We inherit the following instance variables from Paperclip::Processor:
@file the file that will be operated on (which is an instance of File) @options a hash of options that were defined in has_attached_file's style hash @attachment the Paperclip::Attachment itself
Constants
- QUALITY_CONVERT_OPTION_REGEX
- RESOLUTION_CONVERT_OPTION_REGEX
Public Instance Methods
converter_options()
click to toggle source
# File lib/paperclip/pdf_cover_processor.rb, line 20 def converter_options format.merge(jpeg_quality).merge(jpeg_resolution) end
extract_convert_option(key, regex)
click to toggle source
# File lib/paperclip/pdf_cover_processor.rb, line 36 def extract_convert_option(key, regex) match_data = regex.match(@options[:convert_options]) match = match_data && match_data[key] match ? { key => match } : {} end
format()
click to toggle source
# File lib/paperclip/pdf_cover_processor.rb, line 24 def format { format: @options[:format].to_s } end
jpeg_quality()
click to toggle source
# File lib/paperclip/pdf_cover_processor.rb, line 28 def jpeg_quality extract_convert_option(:quality, QUALITY_CONVERT_OPTION_REGEX) end
jpeg_resolution()
click to toggle source
# File lib/paperclip/pdf_cover_processor.rb, line 32 def jpeg_resolution extract_convert_option(:resolution, RESOLUTION_CONVERT_OPTION_REGEX) end
make()
click to toggle source
# File lib/paperclip/pdf_cover_processor.rb, line 16 def make ::PdfCover::Converter.new(@file, converter_options).converted_file end