This is the error I get everytime I try to upload an image using the flexinode image add-on:


    * warning: Division by zero in /home/rdieu/public_html/visonsdieu/includes/image.inc on line 125.
    * warning: imagecreatetruecolor(): Invalid image dimensions in /home/rdieu/public_html/visonsdieu/includes/image.inc on line 225.
    * warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/rdieu/public_html/visonsdieu/includes/image.inc on line 226.
    * warning: imagejpeg(): supplied argument is not a valid Image resource in /home/rdieu/public_html/visonsdieu/includes/image.inc on line 300.
    * warning: imagedestroy(): supplied argument is not a valid Image resource in /home/rdieu/public_html/visonsdieu/includes/image.inc on line 229.

Can somebody fix this?

Comments

llizards’s picture

I had the Same Issue.. Under the edit fields - Make sure you fill out all of the options located there. After I assigned values to those it worked just fine for me.

jeforma’s picture

What do you mean by fill out all the options there? I thought I tried everything to make it work? :(

ardas’s picture

Guys,

This is an error of image_scale function from image.inc.
The problem occures when you try to pass a zero in width or height parameter.

Here is a new (patched) image_scale function:

function image_scale($source, $destination, $width, $height) {
  $info = image_get_info($source);

  // don't scale up
  if ($width > $info['width'] && $height > $info['height']) {
    return false;
  }

  $aspect = $info['height'] / $info['width'];

  if ($width == 0) {
    $height = (int)min($height, $info['height']);
    $width = (int)round($height / $aspect);
  } elseif ($height == 0) {
    $width = (int)min($width, $info['width']);
    $height = (int)round($width * $aspect);
  } elseif ($aspect < $height / $width) {
    $width = (int)min($width, $info['width']);
    $height = (int)round($width * $aspect);
  } else {
    $height = (int)min($height, $info['height']);
    $width = (int)round($height / $aspect);
  }

  return image_toolkit_invoke('resize', array($source, $destination, $width, $height));
}
Bèr Kessels’s picture

Component: Code » Field type: image
Status: Active » Closed (duplicate)