regularly when imagecache images are accessed by pages I get the following warnings - which are also shown to anonymous users. I know all the options are disabled, but I don't want anonymous users to keep seeing errors about it. Can anyone tell me how to get rid of them?

warning: imagealphablending() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 260.
warning: imagecolorallocatealpha() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 261.
warning: imagefill() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 262.
warning: imagealphablending() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 263.
warning: imagesavealpha() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 264.
warning: imagealphablending() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 260.
warning: imagecolorallocatealpha() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 261.
warning: imagefill() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 262.
warning: imagealphablending() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 263.
warning: imagesavealpha() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 264.
warning: imagealphablending() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 71.
warning: imagesavealpha() has been disabled for security reasons in sites/all/modules/imageapi/imageapi_gd.module on line 72.

Comments

avpaderno’s picture

Category: bug » support

You should check your web server configuration. The GD functions are disabled on the server; there is nothing that the module can do in such cases.
The module requires the GD functions to be enabled, but that is not happening on your server.

mbiddlecombe’s picture

That may be the case, but I cannot change the GD2 options on our hosted web server. I have been told they have been disabled to save memory.

I only used the imageapi to scale and crop, so it seems disappointing to receive warnings about features that I am not trying to use. Is there no way to suppress these warnings?

avpaderno’s picture

I checked the function that crop an image, and the functions you reported are used by that function. In this case, you cannot do too much; or those functions are enabled on the server, or you cannot use ImageAPI.

function imageapi_gd_image_crop(&$image, $x, $y, $width, $height) {
  $res = imageapi_gd_create_tmp($image, $width, $height);

  if (!imagecopyresampled($res, $image->resource, 0, 0, $x, $y, $width, $height, $width, $height)) {
    return FALSE;
  }

  // Destroy the original image and return the modified image.
  imagedestroy($image->resource);
  $image->resource = $res;
  $image->info['width'] = $width;
  $image->info['height'] = $height;
  return TRUE;
}

function imageapi_gd_create_tmp($image, $width, $height) {
  $res = imagecreatetruecolor($width, $height);

  if ($image->info['extension'] == 'gif') {
    // Grab transparent color index from image resource.
    $transparent = imagecolortransparent($image->resource);

    if ($transparent >= 0) {
      // The original must have a transparent color, allocate to the new image.
      $transparent_color = imagecolorsforindex($image->resource, $transparent);
      $transparent = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);

      // Flood with our new transparent color.
      imagefill($res, 0, 0, $transparent);
      imagecolortransparent($res, $transparent);
    }
  }
  elseif ($image->info['extension'] == 'png') {
    imagealphablending($res, FALSE);
    $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
    imagefill($res, 0, 0, $transparency);
    imagealphablending($res, TRUE);
    imagesavealpha($res, TRUE);
  }
  else {
    imagefill($res, 0, 0, imagecolorallocate($res, 255, 255, 255));
  }

  return $res;
}
drewish’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.