Hi,

This is not a patch, but more of a code dump of what I am using just now. I had problems with large images (1280x720) and I also think with images with spaces in URL.

I changed to using CURL and I no longer had problems with large images.

Many other things in drupal also use curl, so it should be fine to use that.

Especially nice is that the data does not need to be read into memory first and then saved, but is saved to file directly.

I think there needs to be some more error checking though ...

image_resize_filter was very slow on these and blocked my import process (even though image was imported from localhost):

diff --git a/sites/all/modules/content/image_resize_filter/image_resize_filter.module b/sites/all/modules/content/image_resize_filter/image_resize_filter.module
index cd48c66..4e7831c 100644
--- a/sites/all/modules/content/image_resize_filter/image_resize_filter.module
+++ b/sites/all/modules/content/image_resize_filter/image_resize_filter.module
@@ -385,14 +385,28 @@ function image_resize_filter_get_images($settings, $text) {
 
     // If this is a remote image, retreive it to check its size.
     if ($location == 'remote') {
-      $result = drupal_http_request($src);
-      if ($result->code == 200) {
+                $filepath = tempnam(file_directory_temp(), 'image_resize_filter_');
+                $url=str_replace(' ', '%20', $src);
+                 echo "Downloading (RS) $url ... \n";
+
+                 $fp = fopen($filepath, 'w');
+
+                 $ch = curl_init();
+                 curl_setopt($ch, CURLOPT_URL, $url); 
+                 curl_setopt($ch, CURLOPT_FILE, $fp);
+                 $data = curl_exec($ch);
+                 curl_close($ch);
+                 fclose($fp);
+               $local_path = $filepath;
+
+//      $result = drupal_http_request($src);
+/*      if ($result->code == 200) {
         $tmp_file = tempnam(file_directory_temp(), 'image_resize_filter_');
         $handle = fopen($tmp_file, 'w');
         fwrite($handle, $result->data);
         fclose($handle);
-        $local_path = $tmp_file;
-      }
+    	    $local_path = $tmp_file;
+      }*/
     }
 
     // Get the image size.

Perhaps it can help anyway,

Best Wishes,

Fabian (LionsAd)

Comments

quicksketch’s picture

I'd be open to using cURL as an alternative if it is available, but I don't think that it should be the only option (a lot of sites don't have cURL available). I'm also curious to have some benchmarks, since if it's faster/more efficient it should be the default.

ram4nd’s picture

Status: Needs work » Closed (works as designed)

drupal_http_request is the right way.

Fabianx’s picture

Status: Closed (works as designed) » Closed (won't fix)

drupal_http_request() won't work for large images, but I am happy with this not being fixed as I don't use that module anymore anyway :).

ram4nd’s picture

I think it had to be server side issue ors. I have never had any problems with the function.