{"issue":{"title":"Cannot convert multipage PDFs to JPG with RMagick","user":{"login":"chanind","id":200725,"url":"https://api.github.com/users/chanind","avatar_url":"https://secure.gravatar.com/avatar/0a7f07ece6764ad8f97936ef14bee2f2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"0a7f07ece6764ad8f97936ef14bee2f2"},"created_at":"2011-11-05T01:55:40Z","milestone":null,"state":"closed","updated_at":"2011-12-26T18:51:36Z","labels":[],"id":2150296,"closed_at":"2011-12-25T16:12:52Z","pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/jnicklas/carrierwave/issues/517","body":"When using process :convert => 'jpg' on a multipage PDF carrierwave throws a LocaJumpError. The reason is that convert calls manipulate!, but does not pass in a block.\r\n\r\nA possible solution is to replace the current manipulate! method under / lib / carrierwave / processing / rmagick.rb with the following:\r\n\r\n```ruby\r\n    def manipulate!(options={})\r\n      cache_stored_file! if !cached?\r\n      image = ::Magick::Image.read(current_path)\r\n\r\n      frames = if image.size > 1\r\n        list = ::Magick::ImageList.new\r\n        image.each do |frame|\r\n            list << (block_given? ? yield( frame ) : frame)\r\n        end\r\n        block_given? ? list : list.append(true)\r\n      else\r\n        frame = image.first\r\n        frame = yield( frame ) if block_given?\r\n        frame\r\n      end\r\n\r\n      if options[:format]\r\n        frames.write(\"#{options[:format]}:#{current_path}\")\r\n      else\r\n        frames.write(current_path)\r\n      end\r\n      destroy_image(frames)\r\n    rescue ::Magick::ImageMagickError => e\r\n      raise CarrierWave::ProcessingError, I18n.translate(:\"errors.messages.rmagick_processing_error\", :e => e)\r\n    end\r\n```\r\n\r\nThis turns the multipage image into a single page image if no block is provided. Not sure if this is the best solution though as I think multilayer images will not convert properly using this approach (in theory they're just throwing an error on convert though anway...)","number":517,"url":"https://api.github.com/repos/jnicklas/carrierwave/issues/517","comments":11,"assignee":null},"comment":{"user":{"login":"counterbeing","id":239798,"url":"https://api.github.com/users/counterbeing","avatar_url":"https://secure.gravatar.com/avatar/ba24b0a226c1f5e751346d6f8d59958f?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"ba24b0a226c1f5e751346d6f8d59958f"},"created_at":"2011-12-26T18:51:36Z","updated_at":"2011-12-26T18:51:36Z","id":3276197,"body":"I don't know much about writing specs, but I was sort of thinking that you would have the ability to specify a particular page of the pdf to work with, or else it would default to the first page of the pdf… Anyone else have any thoughts on that?\r\n\r\nOn Dec 26, 2011, at 10:33 AM, Aaron Cruz wrote:\r\n\r\n> @trevorturk I have no idea how to write specs for this.  Do you have any advice?\r\n> \r\n> --- \r\n> Reply to this email directly or view it on GitHub:\r\n> https://github.com/jnicklas/carrierwave/issues/517#issuecomment-3276083","url":"https://api.github.com/repos/jnicklas/carrierwave/issues/comments/3276197"},"action":"created"}