5

I just migrated from Magento 1.9.3.8 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

Updated

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

2

3 Answers 3

6
+50

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

vendor/magento/framework/Image/Adapter/Gd2.php:64

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

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

5
  • i already fixed the libpng problem , but the wrong file problem still exist Commented 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 Commented 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 Commented 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. Commented Feb 24, 2020 at 5:05
  • Glad it helped @jojo. You can accept the answer Commented Feb 24, 2020 at 7:30
2

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 {} \;
1
  • It helps me to find empty file so i can solve it. Thank you Commented Dec 24, 2021 at 5:04
0

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.