This error might occurred due to an unsupported file format or bad quality of PNG image. imagepng which should have a valid quality format between 1 and 9.
Check the var/log directory for the corrupted catalog image, then remove the corrupted image & re-add the updated image. Hopefully it will fix your issue!
I faced the same issue after extending a class.
The problem was that there was a backslash missing:
class AbstractProduct extends Magento\Catalog\Block\Product\AbstractProduct
class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractProduct
I have not dealt with this issue myself, and resize is working fine on our M234 stores.
Although the catalog resize function works by pulling the image paths from the database, so it seems like either a DB connection / data issue.
Below I've linked where the error is thrown, having a deeper look into the getCountUsedProductImages method and running ...