Last active
August 29, 2015 14:02
-
-
Save harikrishnan83/c9c94cd9b67842516af8 to your computer and use it in GitHub Desktop.
Convert all pages with Carrierwave::MiniMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MiniMagick::Image.format method by default converts only the first page. | |
# Carrierwave::MiniMagick.convert(:pdf) does not allow us to pass a second parameter page = nil. | |
# We need to paste in below code in the carrierwave initializer (or you may choose to extract it to lib folder) | |
# and use convert_all_pages_to_pdf in you uploader. | |
module CarrierWave | |
module MiniMagick | |
def convert_all_pages_to_pdf | |
manipulate! do |img| | |
img.format('pdf', nil) | |
img = yield(img) if block_given? | |
img | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Latest versions of CarrierWave should not have this issue.
carrierwaveuploader/carrierwave#1408