Obay Obay - 1 month ago 14x
PHP Question

wrap phpThumb in a CodeIgniter controller method

On Codeigniter, I'm using phpThumb to generate images. I didn't use the built-in CI image library because it couldn't do the "zoom-crop" feature of phpThumb, which I badly need (ability to create thumbnails of the same size regardless of their original size/proportions, by zooming and cropping when necessary).

Everything is working fine except my images'

look so ugly:

<img src="lib/phpThumb.php?src=../../upload/photo/file.jpg&w=100&h=100&zc=1" />

I was hoping to make it look something like this instead:

<img src="photo/display/file.jpg" />

by wrapping phpThumb in a CI controller
with the method
display($filename) {}

I was able to do this using the built-in CI image library, but I'm at a loss on how to use phpThumb instead.

Any suggestions?


I found a different PHP thumbnailing library (also called PHPThumb) and used it: https://github.com/masterexploder/PHPThumb/wiki

Here's my CodeIgniter class:

class Photo extends CI_Controller {

    function __construct() {

    function display($filename) {
        $thumb = PhpThumbFactory::create('./upload/photo/' . $filename);
        $thumb->adaptiveResize(100, 100);


Now my img looks better:

<img src="photo/display/file.jpg" />