<?php

$fileName = ('https://alunos.b7web.com.br/media/courses/php.jpg');

list($width, $height) = getimagesize($fileName);
$newwidth = 400;
$newheight = 283;

$thumb = imagecreatetruecolor($newwidth, $newheight);

imagealphablending($thumb, false);

imagesavealpha($thumb, true);

$trans = imagecolorallocatealpha($thumb, 220, 220, 220, 127);
imagefill($thumb, 0, 0, $trans);

$source = imagecreatefrompng($fileName);
imagealphablending($source, true);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

header('Content-Type: image/png');

imagepng($thumb, 'test.png');

imagedestroy($thumb);
imagedestroy($source);