lib/carrierwave/processing/mini_magick.rb
def minimagick!(block = nil)
      builder = ImageProcessing::MiniMagick.source(current_path)
      builder = yield(builder)

      result = builder.call
      result.close

      # backwards compatibility (we want to eventually move away from MiniMagick::Image)
      if block
        image  = ::MiniMagick::Image.new(result.path, result)
        image  = block.call(image)
        result = image.instance_variable_get(:@tempfile)
      end

      FileUtils.mv result.path, current_path

      if File.extname(result.path) != File.extname(current_path)
        move_to = current_path.chomp(File.extname(current_path)) + File.extname(result.path)
        file.content_type = Marcel::Magic.by_path(move_to).try(:type)
        file.move_to(move_to, permissions, directory_permissions)
      end
    rescue ::MiniMagick::Error, ::MiniMagick::Invalid
      message = I18n.translate(:"errors.messages.processing_error")
      raise CarrierWave::ProcessingError, message
    end
# Process the image with MiniMagick, using the ImageProcessing gem. This
# method will build a "convert" ImageMagick command and execute it on the
# current image.
#
# === 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
#
# [ImageProcessing::Builder] use it to define processing to be performed
#
# === Raises
#
# [CarrierWave::ProcessingError] if processing failed.
Process the image with MiniMagick, using the ImageProcessing gem. This
method will build a "convert" ImageMagick command and execute it on the
current image.

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

[ImageProcessing::Builder] use it to define processing to be performed

Raises


Process the image with MiniMagick using the ImageProcessing gem . This method will build a " convert " ImageMagick command and execute it on the current image . 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 [ ImageProcessing :: Builder ] use it to define processing to be performed Raises
def minimagick!(block = nil)
      builder = ImageProcessing::MiniMagick.source(current_path)
      builder = yield(builder)
      result = builder.call
      result.close
      if block
        image  = ::MiniMagick::Image.new(result.path, result)
        image  = block.call(image)
        result = image.instance_variable_get(:@tempfile)
      end
      FileUtils.mv result.path, current_path
      if File.extname(result.path) != File.extname(current_path)
        move_to = current_path.chomp(File.extname(current_path)) + File.extname(result.path)
        file.content_type = Marcel::Magic.by_path(move_to).try(:type)
        file.move_to(move_to, permissions, directory_permissions)
      end
    rescue ::MiniMagick::Error, ::MiniMagick::Invalid
      message = I18n.translate(:"errors.messages.processing_error")
      raise CarrierWave::ProcessingError, message
    end
def minimagick! ( block = nil ) builder = ImageProcessing :: MiniMagick . source ( current_path ) builder = yield ( builder ) result = builder . call result . close if block image = :: MiniMagick :: Image . new ( result . path , result ) image = block . call ( image ) result = image . instance_variable_get ( :@tempfile ) end FileUtils . mv result . path , current_path if File . extname ( result . path ) != File . extname ( current_path ) move_to = current_path . chomp ( File . extname ( current_path ) ) + File . extname ( result . path ) file . content_type = Marcel :: Magic . by_path ( move_to ) . try ( :type ) file . move_to ( move_to , permissions , directory_permissions ) end rescue :: MiniMagick :: Error , :: MiniMagick :: Invalid message = I18n . translate ( :" errors.messages.processing_error " ) raise CarrierWave :: ProcessingError , message end
Process the image with MiniMagick, using the ImageProcessing gem.
Process the image with MiniMagick using the ImageProcessing gem .
# backwards compatibility (we want to eventually move away from MiniMagick::Image)
block