<?php

namespace App\Controllers;

use CodeIgniter\Controller;

class ImageRenderer extends Controller
{
    public function index($imagepath)
    {
        if(($image = file_get_contents($imagepath)) === FALSE)
            show_404();

        // choose the right mime type
        $mimeType = 'image/jpg';

        $this->response
            ->setStatusCode(200)
            ->setContentType($mimeType)
            ->setBody($image)
            ->send();

    }

}