I have a news aggregator site that grabs an image from a remote URL but the script is breaking with the following error when I try to crop the file after grabbing:
Expected the file at /home/vagrant/code/storage/media-library/temp/pemA8JMvkodnsavxgk5ZLXXHxeU3wo7n/tiny.jpg have mimetype image/jpeg, but found a file with mimetype image/png
I have no control over this image so I was wondering if there is a way to either correct the mimetype or to catch the error and remove the offending article?
Thanks in advance for your help
edit: For clarity I am grabbing the image with:
$article->addMediaFromUrl($item['article']['image'])->toMediaCollection('article');
and then running:
$article->save();
The model has the following function:
public function registerMediaConversions(Media $media = null): void {
$this->addMediaConversion('listing')
->fit(Manipulations::FIT_CROP, 140, 140)
->performOnCollections('article');
}