lib/image_processing/pipeline.rb
def handle_destination
      destination_existed = File.exist?(destination)
      yield
    rescue
      File.delete(destination) if File.exist?(destination) && !destination_existed
      raise
    end
def handle_destination
      destination_existed = File.exist?(destination)
      yield
    rescue
      File.delete(destination) if File.exist?(destination) && !destination_existed
      raise
    end
In case of processing errors, both libvips and imagemagick will leave the
 empty destination file they created, so this method makes sure it is
 deleted in case an exception is raised on saving the image.