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.

Note: the image system API is still undergoing changes. Please refer to meta #2105863: [meta] Images, toolkits and operations for more information.

Image loading and saving

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

Image information

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

Image manipulation

What Drupal 7 Drupal 8
Create a new image: n/a
<?php
 $image
->createNew($width, $height, 'jpeg');
?>
Scale and crop image:
<?php
 image_scale_and_crop
($image, $width, $height);
?>
<?php
 $image
->scaleAndCrop($width, $height);
?>
Scale image:
<?php
 image_scale
($image, $width, $height);
?>
<?php
 $image
->scale($width, $height);
?>
Resize image:
<?php
 image_resize
($image, $width, $height);
?>
<?php
 $image
->resize($width, $height);
?>
Rotate image:
<?php
 image_rotate
($image, $degrees);
?>
<?php
 $image
->rotate($degrees);
?>
Crop image:
<?php
 image_crop
($image, $x, $y, $width, $height);
?>
<?php
 $image
->crop($x, $y, $width, $height);
?>
Desaturate image (convert to grayscale):
<?php
 image_desaturate
($image);
?>
<?php
 $image
->desaturate();
?>
Convert image to a different format: n/a
<?php
 $image
->convert('jpeg');
?>
Apply a custom toolkit operation to the image:
<?php
 image_toolkit_invoke
('my_op', $image, array('p1' => $parm1, 'p2' => $parm2));
?>
<?php
 $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
<?php
 $toolkit
= $image->getToolkit();
?>
Get the ID of the image toolkit: N/A
<?php
 $toolkit_id
= $image->getToolkitId();
?>
GD Toolkit - get the standard file extension
of the image, based on its
internal type (for GD, jpeg/png/gif):
<?php
 $info
= image_get_info($image);
$extension = $info['extension'];
?>
<?php
 $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