diff --git a/imagemagick.module b/imagemagick.module
index 804338f..fa5a0e3 100644
--- a/imagemagick.module
+++ b/imagemagick.module
@@ -347,7 +347,7 @@ function image_imagemagick_save(stdClass $image, $destination) {
  */
 function image_imagemagick_get_info(stdClass $image) {
   $details = FALSE;
-  $data = getimagesize(drupal_realpath($image->source));
+  $data = getimagesize($image->source);
 
   if (isset($data) && is_array($data)) {
     $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
@@ -371,10 +371,30 @@ function _imagemagick_convert($source, $destination, $args) {
   $source_original = $source;
   $destination_original = $destination;
 
-  $source = drupal_realpath($source);
-  $destination = drupal_realpath($destination);
-  $destination_format = '';
+  $local_streams = variable_get('imagemagick_local_streams', array('private', 'public', 'temporary'));
+  $scheme = file_uri_scheme($source_original);
+  $source = drupal_realpath($source_original);
+  // If drupal_realpath() returned FALSE or the scheme is not whitelisted as
+  // being local, we're working with a remote source.
+  // Copy the file to a temporary path and work from the local copy.
+  if (!$source || !in_array($scheme, $local_streams)) {
+    $source_temp = drupal_tempnam('temporary://', 'imagemagick_');
+    $source_temp .= '.' . pathinfo($source_original, PATHINFO_EXTENSION);
+    $source_temp = file_unmanaged_copy($source_original, $source_temp, FILE_EXISTS_ERROR);
+    $source = drupal_realpath($source_temp);
+  }
 
+  $destination = drupal_realpath($destination_original);
+  // If drupal_realpath() returned FALSE, we're working with a remote
+  // destination. Save the file to a temporary path and move it when finished.
+  if (!$destination) {
+    $destination = drupal_tempnam('temporary://', 'imagemagick_');
+    $destination .= '.' . pathinfo($destination_original, PATHINFO_EXTENSION);
+    $destination = drupal_realpath($destination);
+    $remote_destination = TRUE;
+  }
+
+  $destination_format = '';
   $args['quality'] = '-quality ' . escapeshellarg(variable_get('imagemagick_quality', 75));
 
   // Allow other modules to alter the ImageMagick command line parameters.
@@ -418,6 +438,16 @@ function _imagemagick_convert($source, $destination, $args) {
   if (_imagemagick_convert_exec($command_args, $output, $error) !== TRUE) {
     return FALSE;
   }
+
+  // If we copied down the source, remove the temporary local file.
+  if (!empty($source_temp)) {
+    unlink($source_temp);
+  }
+
+  // If the destination is remote, move the temporary file there.
+  if (!empty($remote_destination)) {
+    return (bool) file_unmanaged_move($destination, $destination_original);
+  }
   return file_exists($destination);
 }
 
