Created
January 18, 2013 19:19
-
-
Save haywoood/4567494 to your computer and use it in GitHub Desktop.
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
class FileUploader < CarrierWave::Uploader::Base | |
require 'carrierwave/processing/mini_magick' | |
include CarrierWave::MiniMagick | |
storage :fog | |
version :thumb do | |
process :resize_first_page | |
process :convert => :jpg | |
process :set_content_type | |
end | |
private | |
def resize_first_page | |
manipulate! do |pdff| | |
first_page = Magick::ImageList.new("#{current_path}[0]").first | |
thumb = first_page.resize_to_fill!(220,155) | |
thumb | |
end | |
end | |
def set_content_type(*args) | |
self.file.instance_variable_set(:@content_type, "image/jpg") | |
end | |
end |
@atstockland I'm getting a maybe it is not an image?
error when it enters manipulate!
, did you experience this at all?
+1 @sighmin did you find a workaround ?
ImageList in MiniMagick was removed. It was in beta and the developer concluded that it wasted too much memory to be included sadly :/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Even 3 years old this seems to be a valid way to convert a PDF cover page. However, Magick::ImageList.new results in the error uninitialized constant Magick::ImageList. Are you aware if anything has changed with MiniMagick that makes this method no longer available? Thanks!