I'm trying to scale an image and return it with the image header. It works to just display the image as it is, but as soon as I try to scale it, nothing shows on the webpage.
<?php
if(isset($_GET["width"])) {
$size = $_GET["width"] <= 1000 ? $_GET["width"] : 1000;
$imageFile = file_get_contents('no-image.png', true);
$image = imagescale($imageFile, $size);
header("Content-Type: image/png");
header("Content-Length: " . getimagesize($image));
echo $image;
return;
}
?>
I used the filesize() method to get the filesize of the image directly on the server, but that method did only support a string so I'm not sure if the getimagesize() method is causing the issue here. Any idea?
Thanks in advance!