For resize product image in Magento 2, You need to refer below code snippet for resizing product image at any place in the file.
You need to call helper file, Magento\Catalog\Helper\Image to resize product image.
Call Init() function and pass parameters,
First parameter as $product Object,
The second parameter as product id, You can be called any product id like thumbnail,small_image (Check the list of image id under the theme etc/view.xml file)
Third parameter as array its optional,
For Custom Image resize refer blog, Resize custom image in Magento 2
<?php $imageHelper = $this->helper('Magento\Catalog\Helper\Image'); $product = $productObject; // Fetch Product Object $productImage = $imageHelper->init($product, 'thumbnail', ['type'=>'thumbnail']) ->constrainOnly(TRUE) ->keepAspectRatio(TRUE) ->keepTransparency(TRUE) ->resize('256','128') ->getUrl();
Return Product resizes url as output.