Magento is one of the most preferred platforms for creating E-commerce stores. And that is for a reason!
The platform powered by Adobe keeps on releasing new versions frequently to stay up to date with the latest technology and increasing business demands.
It is recommended that merchants migrate their Magento 2 stores to the latest version Magento 2.4.8 in order to avail the performance and security benefits.
However, while installing Magento 2.3.5 or its above versions, you may face an error that says,
Unable to apply data patch MagentoThemeSetupPatchDataRegisterThemes for module Magento_Theme. Original exception message: Wrong file
Today, I will be talking about the solution for solving the error InvalidArgumentException error in Magento 2.3.5 or above version.
Solution for InvalidArgumentException Error in Magento 2.3.5 in Gd2.php:64
The below image shows the error that occurs while installing Magento 2.3.5.
The command prompt shows the line 64. However, if you open the file in edit mode, you need to make changes in it at line 96.

Open vendor\magento\framework\Image\Adapter\Gd2.php.
At line 96, replace:
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) { return false; } return true; }
With the below code:
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; }
All you have to do is to replace the below string:
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes
With:
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename))
That’s it.
Do consider sharing this post with the Magento community via social media.
Thank you.