Chris@0: 50, 'height' => 100, 'upscale' => TRUE] Chris@0: * @endcode Chris@0: * Defaults to an empty array. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function apply($operation, array $arguments = []); Chris@0: Chris@0: /** Chris@0: * Closes the image and saves the changes to a file. Chris@0: * Chris@0: * @param string|null $destination Chris@0: * (optional) Destination path where the image should be saved. If it is empty Chris@0: * the original image file will be overwritten. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: * Chris@0: * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::save() Chris@0: */ Chris@0: public function save($destination = NULL); Chris@0: Chris@0: /** Chris@0: * Prepares a new image, without loading it from a file. Chris@0: * Chris@0: * For a working example, see Chris@0: * \Drupal\system\Plugin\ImageToolkit\Operation\gd\CreateNew. Chris@0: * Chris@0: * @param int $width Chris@0: * The width of the new image, in pixels. Chris@0: * @param int $height Chris@0: * The height of the new image, in pixels. Chris@0: * @param string $extension Chris@0: * (optional) The extension of the image file (for instance, 'png', 'gif', Chris@0: * etc.). Allowed values depend on the implementation of the image toolkit. Chris@0: * Defaults to 'png'. Chris@0: * @param string $transparent_color Chris@0: * (optional) The hexadecimal string representing the color to be used Chris@0: * for transparency, needed for GIF images. Defaults to '#ffffff' (white). Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function createNew($width, $height, $extension = 'png', $transparent_color = '#ffffff'); Chris@0: Chris@0: /** Chris@0: * Scales an image while maintaining aspect ratio. Chris@0: * Chris@0: * The resulting image can be smaller for one or both target dimensions. Chris@0: * Chris@0: * @param int|null $width Chris@0: * The target width, in pixels. If this value is null then the scaling will Chris@0: * be based only on the height value. Chris@0: * @param int|null $height Chris@0: * (optional) The target height, in pixels. If this value is null then the Chris@0: * scaling will be based only on the width value. Chris@0: * @param bool $upscale Chris@0: * (optional) Boolean indicating that files smaller than the dimensions will Chris@0: * be scaled up. This generally results in a low quality image. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function scale($width, $height = NULL, $upscale = FALSE); Chris@0: Chris@0: /** Chris@0: * Scales an image to the exact width and height given. Chris@0: * Chris@0: * This function achieves the target aspect ratio by cropping the original Chris@0: * image equally on both sides, or equally on the top and bottom. This Chris@0: * function is useful to create uniform sized avatars from larger images. Chris@0: * Chris@0: * The resulting image always has the exact target dimensions. Chris@0: * Chris@0: * @param int $width Chris@0: * The target width, in pixels. Chris@0: * @param int $height Chris@0: * The target height, in pixels. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function scaleAndCrop($width, $height); Chris@0: Chris@0: /** Chris@0: * Instructs the toolkit to save the image in the format specified by the Chris@0: * extension. Chris@0: * Chris@0: * @param string $extension Chris@0: * The extension to convert to (for instance, 'jpeg' or 'png'). Allowed Chris@0: * values depend on the current image toolkit. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: * Chris@0: * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::getSupportedExtensions() Chris@0: */ Chris@0: public function convert($extension); Chris@0: Chris@0: /** Chris@0: * Crops an image to a rectangle specified by the given dimensions. Chris@0: * Chris@0: * @param int $x Chris@0: * The top left coordinate, in pixels, of the crop area (x axis value). Chris@0: * @param int $y Chris@0: * The top left coordinate, in pixels, of the crop area (y axis value). Chris@0: * @param int $width Chris@0: * The target width, in pixels. Chris@0: * @param int $height Chris@0: * The target height, in pixels. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function crop($x, $y, $width, $height = NULL); Chris@0: Chris@0: /** Chris@0: * Resizes an image to the given dimensions (ignoring aspect ratio). Chris@0: * Chris@0: * @param int $width Chris@0: * The target width, in pixels. Chris@0: * @param int $height Chris@0: * The target height, in pixels. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function resize($width, $height); Chris@0: Chris@0: /** Chris@0: * Converts an image to grayscale. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function desaturate(); Chris@0: Chris@0: /** Chris@0: * Rotates an image by the given number of degrees. Chris@0: * Chris@0: * @param float $degrees Chris@0: * The number of (clockwise) degrees to rotate the image. Chris@0: * @param string|null $background Chris@0: * (optional) An hexadecimal integer specifying the background color to use Chris@0: * for the uncovered area of the image after the rotation; for example, Chris@0: * 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. When Chris@0: * NULL (the default) is specified, for images that support transparency, Chris@0: * this will default to transparent; otherwise, it will default to white. Chris@0: * Chris@0: * @return bool Chris@0: * TRUE on success, FALSE on failure. Chris@0: */ Chris@0: public function rotate($degrees, $background = NULL); Chris@0: Chris@0: }