Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mini_magick convert #1408

Merged
merged 2 commits into from Nov 19, 2014
Merged

Conversation

harikrishnan83
Copy link
Contributor

MiniMagick.convert by default only converts the first page of tif files to pdf when using below code.

class TestUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick

  version :pdf do
    process convert: 'pdf'
  end
end

After reading throw MiniMagick, I realised that mini_magick makes a poor assumption that by default it will only convert first page. So I had to use below code to convert all pages.

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

This PR fixes convert to format all pages by default and adds an optional page number parameter to convert specific pages

process convert: 'pdf' #Convert all pages
process convert: ['pdf', 0] #Convert first page

bensie added a commit that referenced this pull request Nov 19, 2014
@bensie bensie merged commit 36bce8c into carrierwaveuploader:master Nov 19, 2014
@bensie
Copy link
Member

bensie commented Nov 19, 2014

Thanks @harikrishnan83!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants