--- imagecache.module +++ imagecache.module @@ -197,6 +197,15 @@ } break; case 'crop': + // Patch to ensure images dont get cropped to a larger size if they are smaller than the crop size, otherwise they will get a black background + if ($action['data']['width'] > $size[0]) { + $action['data']['width'] = $size[0]; + $action['data']['xoffset'] = 0; + } + if ($action['data']['height'] > $size[1]) { + $action['data']['height'] = $size[1]; + $action['data']['yoffset'] = 0; + } if (!image_crop($tmpdestination, $tmpdestination, $action['data']['xoffset'], $action['data']['yoffset'], $action['data']['width'], $action['data']['height'])) { watchdog('imagecache', t('Imagecache crop action ID %id failed.', array('%id' => $action['actionid'])), WATCHDOG_ERROR); }