I'm processing thumbnail for PDF file in this way:
version :thumb do
process :resize_to_limit => [260, 192]
process :convert => :jpg
process :set_content_type
end
def set_content_type(*args)
self.file.instance_variable_set(:@content_type, "image/jpeg")
end
But when PDF file is multipage it produces thumbnail for all pages in one jpg file. Is there any way to produce thumbnail only for first page?
I submitted a patch earlier this year to do just this. Use a custom processor:
def cover
manipulate! do |frame, index|
frame if index.zero?
end
end
process :cover
Great solution by Tanzeeb! Thank you.
So i could do something like this:
def cover
manipulate! do |frame, index|
frame if index.zero?
end
end
and used this for the thumb generation
version :thumb do
process :cover
process :resize_to_fill => [50, 50, Magick::NorthGravity]
process :convert => 'png'
end
great!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With