Welcome Guest, Not a member yet? Register   Sign In
problem with image_lib in on-the-fly resize image
#1

[eluser]Pierre Sandora[/eluser]
Hello,

I have a problem with this code, but I dont know where. The image was not displayed, however, none error was showed and $this->image_lib->resize() returned true.

Code:
function exibir_imagem($perfil_atributo_id) { //controller function
        settype($perfil_atributo_id,'integer');
        if (!empty($perfil_atributo_id)) {
            $valor = new valor_model();
            $valor->perfil_atributo_id = $perfil_atributo_id;
            $valor->carrega_conteudo();
            
            $config2['image_library'] = 'gd2';
            $config2['source_image'] = 'C:/workspace/code/system/application/uploads/images/profile/43c314e1e07b71a341d1978eac991aed.JPG';
            $config2['maintain_ratio'] = TRUE;
            $config2['dynamic_output'] = TRUE;
            $config['quality'] =     100;
            $config2['width'] = 75;
            $config2['height'] = 50;

            $this->load->library('image_lib', $config2);
            $this->image_lib->resize();
        }
    }

Response headers:
Quote:Date: Sun, 18 Jan 2009 22:41:48 GMT
Server: Apache/2.2.9 (Win32) PHP/5.2.8
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
content-disposition: filename=43c314e1e07b71a341d1978eac991aed.JPG;
Content-Transfer-Encoding: binary
Last-Modified: Sun, 18 Jan 2009 22:41:48 GMT
Content-Length: 2299
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: image/jpeg

200 OK

In http://localhost/code/usuario/exibir_imagem/80 appear a broken image.
I use Windows, GD2 is ok, my permissions are ok, files were created, why the image dont display?

Thank friends.
#2

[eluser]Pierre Sandora[/eluser]
An information

I wrote a file teste.php with this code and run out of CI:
Code:
ob_start();
        $imagedata = file_get_contents('C:/workspace/code/system/application/uploads/images/profile/d1cff3655cb6e245e143b3fc5348af1f.JPG');
        $length = strlen($imagedata);
        header('Last-Modified: '.date('r'));
        header('Accept-Ranges: bytes');
        header('Content-Length: '.$length);
        header('Content-Type: image/jpeg');
        header('Content-Disposition: filename="'.basename('C:/workspace/code/system/application/uploads/images/profile/d1cff3655cb6e245e143b3fc5348af1f.JPG').'"');
        print($imagedata);
        ob_end_flush();

and teste.php work perfectly.

After I change my controller function with same code of teste.php and appear the same problem again, a broken image. I thought that could be includes before $this->image_lib->resize(), so I put an ob_start() and ob_end_flush() in index.php of the my project, but dont work too.

But now I think that the problem is in the way that I use, maybe there is other way to make this, or in the CI's structure.
#3

[eluser]Pierre Sandora[/eluser]
Solved

I put a
Code:
while (@ob_end_clean());
before call
Code:
$this->image_lib->resize();
. It was a problem of buffer.




Theme © iAndrew 2016 - Forum software by © MyBB