Change record status: 
Project: 
Introduced in branch: 
8.x
Introduced in version: 
8.0-ALPHA3
Description: 

Utility methods in image.inc were removed in favour of a classed image object.
A new service 'image.factory' was added for easy instantiation of image objects using the active image toolkit.

Image loading and saving

What Drupal 7 Drupal 8
Load an image from a file: $image = image_load($file->getFileUri()); $image = Drupal::service('image.factory')->get($file->getUri());
Save image at its original file location: image_save($image); $image->save();

Image information

What Drupal 7 Drupal 8
Get information about the image: image_get_info($image); removed
Check if an image is valid
(i.e. can be manipulated/saved to file storage):
n/a $is_valid = $image->isValid();
Get image width:
 $info = image_get_info($image); 
$width = $info['width']; 
$width = $image->getWidth();
Get image height:
 $info = image_get_info($image); 
$height = $info['height']; 
$height = $image->getHeight();
Get the MIME type of the image file:
 $info = image_get_info($image); 
$mime_type = $info['mime_type']; 
$mime_type = $image->getMimeType();
Get image file size:
 $info = image_get_info($image); 
$filesize = $info['filesize']; 
$filesize = $image->getFileSize();
Get the URI of the image file: N/A $source = $image->getSource();
Get a list of image file extensions supported by the current toolkit: N/A $image_factory = \Drupal::service('image.factory'); $supported_extensions = $image_factory->getSupportedExtensions();

Image manipulation

What Drupal 7 Drupal 8
Create a new image: n/a $image->createNew($width, $height, 'jpeg');
Scale and crop image: image_scale_and_crop($image, $width, $height); $image->scaleAndCrop($width, $height);
Scale image: image_scale($image, $width, $height); $image->scale($width, $height);
Resize image: image_resize($image, $width, $height); $image->resize($width, $height);
Rotate image: image_rotate($image, $degrees); $image->rotate($degrees);
Crop image: image_crop($image, $x, $y, $width, $height); $image->crop($x, $y, $width, $height);
Desaturate image (convert to grayscale): image_desaturate($image); $image->desaturate();
Convert image to a different format: n/a $image->convert('jpeg');
Apply a custom toolkit operation to the image: image_toolkit_invoke('my_op', $image, array('p1' => $parm1, 'p2' => $parm2)); $image->apply('my_op', array('p1' => $parm1, 'p2' => $parm2));

Accessing an Image's toolkit

What Drupal 7 Drupal 8
Access image toolkit instance: N/A $toolkit = $image->getToolkit();
Get the ID of the image toolkit: N/A $toolkit_id = $image->getToolkitId();
GD Toolkit - get the standard file extension
of the image, based on its
internal type (for GD, jpeg/png/gif):
 $info = image_get_info($image); 
$extension = $info['extension']; 
$extension = image_type_to_extension($image->getToolkit()->getType(), FALSE);
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done