• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with image_lib in on-the-fly resize image

[eluser]Pierre Sandora[/eluser]

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.

function exibir_imagem($perfil_atributo_id) { //controller function
        if (!empty($perfil_atributo_id)) {
            $valor = new valor_model();
            $valor->perfil_atributo_id = $perfil_atributo_id;
            $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);

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.

[eluser]Pierre Sandora[/eluser]
An information

I wrote a file teste.php with this code and run out of CI:
        $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').'"');

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.

[eluser]Pierre Sandora[/eluser]

I put a
while (@ob_end_clean());
before call
. It was a problem of buffer.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.