diff --git a/css_emimage.advagg.inc b/css_emimage.advagg.inc
index d56b5ce..474ecae 100644
--- a/css_emimage.advagg.inc
+++ b/css_emimage.advagg.inc
@@ -191,6 +191,7 @@ function css_emimage_advagg_scan_for_changes($filename, $save_changes = FALSE) {
       continue;
     }
     // Strip base path from filename.
+    $image_filename = css_emimage_convert_to_rel($image_filename);
     $image_filename = preg_replace('/^' . preg_quote($GLOBALS['base_path'], '/') . '/i', '', $image_filename);
     if (file_exists($image_filename) == FALSE) {
       continue;
diff --git a/css_emimage.inc b/css_emimage.inc
index f70f6f4..4d26ad3 100644
--- a/css_emimage.inc
+++ b/css_emimage.inc
@@ -79,12 +79,13 @@ function _css_emimage_replace($matches) {
     $url = $matches[2][$i];
     $file = $matches[3][$i];
     $important = stripos($matches[4][$i], '!important') !== FALSE;
-    if ($file && (strpos($file, base_path()) === 0) && ($image = image_get_info($file = substr($file, strlen(base_path()))))) {
+    $image_filename = css_emimage_convert_to_rel($file);
+    if ($file && (strpos($image_filename, base_path()) === 0) && ($image = image_get_info($image_filename = substr($image_filename, strlen(base_path()))))) {
       $ielimit = variable_get('css_emimage_ielimit', 1); // only embed data URIs less than 32KB, thanks IE
       if ($ielimit && ($image['file_size']*1.3333) >= CSS_EMIMAGE_IE_DATAURI_LIMIT) {
         $image = NULL;
       }
-      $token = _css_emimage_collect(array($selector, $property, $url, $file, $important, $image));
+      $token = _css_emimage_collect(array($selector, $property, $url, $image_filename, $important, $image));
       $declaration = str_replace($url, $token, $declaration);
     }
     else {
diff --git a/css_emimage.module b/css_emimage.module
index fe44554..4b8fd3f 100644
--- a/css_emimage.module
+++ b/css_emimage.module
@@ -423,3 +423,23 @@ function _css_emimage_process($styles) {
 
   return $styles;
 }
+
+/**
+ * Converts absolute & protocol relative paths to be self references.
+ *
+ * @param string $path
+ *   Path to check.
+ *
+ * @return string
+ *   The path.
+ */
+function css_emimage_convert_to_rel($path) {
+  $parsed = parse_url($GLOBALS['base_url']);
+  if (!empty($parsed['host'])) {
+    $pos = strpos($path, $parsed['host']);
+    if ($pos !== FALSE) {
+      $path = substr($path, $pos + strlen($parsed['host']));
+    }
+  }
+  return $path;
+}
