Using 'png' extension in Cakephp 3

Hii all,
I need to generate an image (having remote path) with ‘jpeg’ extension as user profile picture in all browsers, so, I’ve a code line like below in ‘routers.php’ file:


The corresponding part in the view looks like below:

echo $this->Html->image([‘controller’=>‘Images’,‘action’=>‘profilePicture’], [‘alt’ => $user[‘username’], ‘data-lock-picture’ => [‘controller’=>‘Images’,‘action’=>‘profilePicture’], ‘_ext’ => ‘jpeg’]);


public function profilePicture() {
$this->render(‘profilePicture’, false);


public function generateImage() {
$src_path = ‘https://…/photo/username.jpg’;
$image_string = file_get_contents($src_path);
if ($image_string !== FALSE) {
$image_identifier = imagecreatefromstring($image_string);

After adding ‘png’ extension in routes.php file:


I’m getting an error message in Mozilla:

“NetworkError: 500 Internal Server Error - http://…/cakephp/images/profilePicture”.

and there is no ‘jpeg’ image shown. But it works fine in Chrome.

Thanks in advance for your help!

The problem was adding extensions in routers.php file. They already exist in “vendor/cakephp/cakephp/src/Validation/Validation.php” file.