Any suggestions on image functions that would be nice? I plan on doing watermarking and thumbnails, but any more are welcome.
Pablo Quiroga wrote on 01/26/11 7:39 pm:I really like a Drupal module called Imagecache. It's very easy to generate thumbnails, resize, crop, etc. You can donwload the files and dig into the code. From the project page: "ImageCache allows you to setup presets for image processing. If an ImageCache derivative doesn't exist the web server's rewrite rules will pass the request to Drupal which in turn hands it off to ImageCache to dynamically generate the file." You should take a look at that. This would be an awesome contribution to Fuel. Maybe this could be included in a package if lead developers doesn't want to include it on Fuel Core.
class Controller_Image extends Controller { public function action_resize($width,$height,$file) { $thumb = \Image::create('/var/www/fuel/public/uploads/'.$file); $thumb->resize($width,$height); $path = DOCROOT . 'image/resize/' . $width .'/'. $height; if( ! file_exists ( $path .'/'. $file ) ) { if( ! file_exists ( $path ) ) { mkdir($path,0755,true); } $thumb->save($path.'/'.$file); } $thumb->show(); }
location ~* (\.jpg|\.png|\.gif)$ { expires 31d; try_files $uri @fuel; #Try to read file first and fall back to @fuel php if not found. }
<img src="path/to/your/image/100/100/myimgage.jpg" />to resize your image to 100 x 100. If image with that size exists it will be served directly from nginx and no php code involved.
Kris K wrote on 2011-03-21:Oh, I fixed those problems in a newer commit (with the load). I forgot to use imagedestroy() when loading a new image in the GD class (Which I assume your using, as in ImageMagick antialias has no effect). I'm really curious about the black rounded corners (Were you saving as an image type with no transparency?). The images would be really helpful, or just make a red box as an example. I was also debating adding a reload() function to reload the image, instead of calling load again. Just a thought.
Kris K wrote on 01/29/11 10:42 pm:Well, couldn't get anything out of the old hdd, but a new one is coming in on Monday (working off a livecd right now). It only took less than a day to write what I had done. Most of the functions of the image_moo could be added, though requiring a recompile of GD is something I'd like to avoid for just the rounding method. I was trying to make them with the imagesetpixel, but the anti-aliasing is out of my league. I'll try to get it right this time around, but I think I'll tackle the easier ones like watermarking and such first. I'll get back to work on this as soon as I get my new hdd. It's too hard without any local storage . Keep the thoughts coming!
\Image::load($full_path) ->quality($quality) ->crop_resize($width, $height) ->save($full_path_thumb, 0666);
\Image::load($full_path) ->crop_resize($width, $height, $quality) ->save($full_path_thumb, 0666);
It looks like you're new here. If you want to get involved, click one of these buttons!