Cambiar el tamaño de la imagen y mostrar sin guardarla

Construí una galería de imágenes y guardé la imagen "tal cual" sin recortarla. Quiero cambiar el tamaño de la imagen sobre la marcha mientras está cargada en el controlador, de modo que cuando cargue el controlador en el navegador, muestre la imagen redimensionada a lo que yo quiera. He añadido el método aMY_Loader, aquí está el código.

function show_image($image, $width, $height) {
    $this->helper('file');
    $image_content = read_file($image);

    //resize image
    $image = imagecreatefromjpeg($image);
    $thumbImage = imagecreatetruecolor(50, 50);
    imagecopyresized($thumbImage, $image, 0, 0, 0, 0, 50, 50, $width, $height);
    imagejpeg($thumbImage,"",85);
    imagedestroy($image);
    imagedestroy($thumbImage);

    header('Content-Length: '.strlen($image_content)); // sends filesize header
    header('Content-Type: '. get_mime_by_extension($image)); // send mime-type header
    header('Content-Disposition: inline; filename="'.basename($image).'";'); // sends filename header
    exit($image_content); // reads and outputs the file onto the output buffer
}

De este código, recibo muchos errores, incluyendo errores de encabezado. ¿Qué estoy haciendo mal?

Errores: (si es útil)

Message: imagejpeg(): Filename cannot be empty

Message: Cannot modify header information - headers already sent by (output started at /Volumes/www/vhosts/ci/system/core/Exceptions.php:185)

Message: strrchr() expects parameter 1 to be string, resource given

Message: Cannot modify header information - headers already sent by (output started at /Volumes/www/vhosts/ci/system/core/Exceptions.php:185)

Message: basename() expects parameter 1 to be string, resource given

Message: Cannot modify header information - headers already sent by (output started at /Volumes/www/vhosts/ci/system/core/Exceptions.php:185)

Respuestas a la pregunta(1)

Su respuesta a la pregunta