So I have a weird issue using the GD library inside Laravel. I can save the file correctly. Base64_encode returns the correct image. But I cant for the life of me get it to show in the browser. In my TestController I have the following:
<?php
namespace App\Http\Controllers;
use App;
use Response;
class TestController extends Controller
{
public function index()
{
$test = imagecreatetruecolor(300, 300);
$background = imagecolorallocate($test, 0, 0, 0);
imagefill($test, 0, 0, $background);
ob_start();
imagepng($test);
$buffer = ob_get_contents();
imagedestroy($test);
ob_end_clean();
$response = Response::make($buffer);
$response->header('Content-Type', 'image/png');
return $response;
}
}
That just returns a broken image.
The Console shows the correct headers. I'm pulling my hair out...