Method: CarrierWave::MiniMagick#manipulate!

Defined in:
lib/carrierwave/processing/mini_magick.rb

#manipulate!Object

Manipulate the image with MiniMagick. This method will load up an image and then pass each of its frames to the supplied block. It will then save the image to disk.

NOTE: This method exists mostly for backwards compatibility, you should probably use #minimagick!.

Gotcha

This method assumes that the object responds to current_path. Any class that this module is mixed into must have a current_path method. CarrierWave::Uploader does, so you won’t need to worry about this in most cases.

Yields

MiniMagick::Image

manipulations to perform

Raises

CarrierWave::ProcessingError

if manipulation failed.



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/carrierwave/processing/mini_magick.rb', line 287

def manipulate!
  cache_stored_file! if !cached?
  image = ::MiniMagick::Image.open(current_path)

  image = yield(image)
  FileUtils.mv image.path, current_path

  ::MiniMagick::Image.new(current_path).identify
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
  raise e if e.message =~ /(You must have .+ installed|is not installed|executable not found|delegate failed)/
  message = I18n.translate(:"errors.messages.processing_error")
  raise CarrierWave::ProcessingError, message
ensure
  image.destroy! if image
end