Drupal 8 images with image style

drupal, drupal-8, image

Solution

Per the change records:

use Drupal\image\Entity\ImageStyle;

$path = 'public://images/image.jpg';
$url = ImageStyle::load('style_name')->buildUrl($path);

Problem

In drupal 7, i use function `image_style_url('style', uri)` to generate new image with style and return image's path. so what will be instead of it in drupal 8? thanks

Original source