Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Image class - save problem
  • I'm trying to use the Image class to save cropped images.
    The ouput is ok, but the saved files have always the same dimensions as the original file. This is the code I'm using
    <code>
    \Image::load($path,true)->preset($preset);
    \Image::save($cache_dir.$savename);
    </code> Any ideas? Thanks in advance.
  • In the following line:
    \Image::load($path,true)->preset($preset); Are you providing a string value or an array of the presets?
  • I've found the problem. The preset was including 'output' as action. Seems that if you call save after ouput (or vice-versa) the image is reloaded before the second action and all the process you've made on the image is lost. I've solved it saving the image, loading the new image, and then output, but sounds like a waste of resources doing it that way.
  • To use save() and output() with each other without needing to load the image again, you need to set the config 'persistence' to true. An example (without changing static config):
    $image = \Image::factory(array('persistence' => true)); // Change to forge for 1.1
    $image->load($path,true)->preset($preset);
    $image->save($cache_dir.$savename);
    
    Or just set it in config/image.php to true. Edit: Fixed some typos :p
  • Great! Thanks for your replay Dudeami.

Howdy, Stranger!

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

In this Discussion