Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
image upload and rescale problem
  • I am uploading images and using image library to create different sizes of original image (original, thumb1, thumb2 variation). Problem is that for the small thumbnail I get this result: http://dl.dropbox.com/u/1207859/imagefail.png It only happens to smallest thumb size. thumb sizes are calculated dynamically... I use this code
                    //original uploaded image size
      $imgsize = @getimagesize($file);
      $w = $imgsize[0];
      $h = $imgsize[1];
          
      $thumb1h = 300;
      $thumb1w = ($w*$thumb1h)/$h;
      $thumbname1 = "image-" . round($thumb1w) . 'x' . $thumb1h . '-' . $originalfn;
      
      $thumb2h = 140;
      $thumb2w = ($w*$thumb2h)/$h;
      $thumbname2 = "image-" . round($thumb2w) . 'x' . $thumb2h . '-' . $originalfn;
    
      Image::load($file)
                        ->config('quality', 100)
                        ->crop_resize($thumb1w, $thumb1h)
                        ->save($uploaddir . DIRECTORY_SEPARATOR . $thumbname1);
      
                    Image::load($file)
                         ->config('quality', 100)
                         ->crop_resize($thumb2w, $thumb2h)
                         ->save($uploaddir . DIRECTORY_SEPARATOR . $thumbname2);
    

    Any idea?
  • There was a problem in the calculating thumbnail width where my result could become a floating point... Image library has problem accepting floating point and was throwing out error. Simple round in thumbnail width calculation did the job!
  • Have you send a pull request to fix this issue? And if not, why not? Alternatively, create an issue describing the problem and your fix, so someone else can pick it up and the community can benefit from our work.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion