using png,
header('Content-Type: image/png');
imagepng(imagecreatefrompng($pathToPng));
using svg,
header('Content-Type: image/svg+xml');
// ???
using png,
header('Content-Type: image/png');
imagepng(imagecreatefrompng($pathToPng));
using svg,
header('Content-Type: image/svg+xml');
// ???
As it was hard to get help from the community, I made a temporary working-script. hope it helps others.
$imgInfo = pathinfo($_GET['img']);
$imgRelativePath = $imgInfo['dirname'];
$imgName = urlencode($imgInfo['filename']);
$imgExtension = str_replace(' ', '+', $imgInfo['extension']);
switch ($imgExtension) {
case 'svg+xml':
set_header('image/svg+xml');
break;
case 'png':
set_header('image/png');
break;
}
$imgPath = sprintf(
'%s/%s.%s',
$imgRelativePath,
$imgName,
$imgExtension);
if ($file = fopen($imgPath,'r')) {
while (!feof($file)) {
print fread($file, 2048);
}
}
function set_header ($contentType) {
header("Content-Type: $contentType");
}