I just migrated from Magento to Magento 2.3.4, then i copied the image from Magento 1.9 media to Magento 2 media, i noticed product images still not showing in my Magento 2 frontend, then i run:

php bin/magento catalog:images:resize

enter image description here

Wrong file

libpng warning: iCCP: known incorrect sRGB profile

I already clean the cache , delete the cache file , reindex, but still same error


i've fixed the libpng error by running, but the wrong file error still exists

find pub/media -type f -iname '*.png' -exec pngcrush -ow -rem allb -reduce {} \;

When i look up the file that causes this error, turns out the file does not exist


3 Answers 3


I don't think it's related to migration in general, but to how your original images are generated Try solution here it should work for you

As for Wrong file exception, it's thrown in


if (!$filename || filesize($filename) === 0) {
        throw new \InvalidArgumentException('Wrong file');

So I suggest you check that the actual file is not empty

  • i already fixed the libpng problem , but the wrong file problem still exist
    – jojo
    Feb 24, 2020 at 3:50
  • Hey @jojo I've checked the code and this error is thrown in vendor/magento/framework/Image/Adapter/Gd2.php:64 It's thrown when the filesize is equals 0 or there's no filename. I suggest you find the file in your screenshot and validate that it's not empty. Also you have masked file name - so can't tell for sure, but you might be using unsupported symbols in file name Feb 24, 2020 at 4:40
  • i've tried to open the file , turns out the file doesn't exist , still need to find a way to bypass this error if the file does not exist
    – jojo
    Feb 24, 2020 at 4:44
  • 2
    You can add filesize check in here vendor/magento/module-media-storage/Service/ImageResize.php:186 like if ($this->mediaDirectory->isFile($originalImagePath) && filesize({path_to_the_file})) so it would just show error without throwing exception which terminates the flow. Feb 24, 2020 at 5:05
  • thanks it works fine
    – jojo
    Feb 24, 2020 at 7:14

I'd like to add to the solution, it's how to find empty files in pub/media/ folder

find ./pub/media/ -type f -empty -exec ls -l {} \;
  • It helps me to find empty file so i can solve it. Thank you Dec 24, 2021 at 5:04

Adding && !file_exists($filename) inside function validateURLScheme of vendor\magento\framework\Image\Adapter\Gd2.php worked for me

 * Checks for invalid URL schema if it exists
 * @param string $filename
 * @return bool
private function validateURLScheme(string $filename) : bool
    $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
    $url = parse_url($filename);
    if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && 
    !file_exists($filename)) {
        return false;

    return true;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.