Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Image Library
  • huglester: Mind sending me the code + config that gives you the black corners? Also, upload the images to http://gfxtub.com/ or another site if you could, would help :) If your using ImageMagick, the rounding methods I used seem to have ill effects on transparent backgrounds (Making circles in the corners with whatever RGB is set for that area, rather than leaving it alone). Need to figure out how to merge the alpha channels instead of overwriting them... The GD method should work fine though :p
  • Hello dudeami, maybe you, by any chance, had a time to look at earlier suggestions?
    how are your jobs? I also wanted to ask if you had a chance to look at the image sharpness? http://d.pr/pn0u Thank you in advance :)
  • Hello again dudeami :) well the problem with borders has gone for me, when I switched to png, but I'll have to play yet with it :) maybe I was just doing smth wrong at the beginning... But here are some real debug, I think the behavior of the lib is not working as it should in some scenarios, look here:
    http://scrp.at/Hl There is also the description of expected result, and what we have got..:)
    Hope i was descriptive :) other than that really good lib. makes images resizing VERY fast and not a big deal:))! cheers!
  • 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.
  • Hi dudeami Do you plan to add image caching etc? Have a look at this CI library it's pretty good. http://codeigniter.com/forums/viewthread/113675/ It would be cool if you could add this to your library. Thanks
  • Any suggestions on image functions that would be nice? I plan on doing watermarking and thumbnails, but any more are welcome.

    -Rounded corners with tranparency.
    -Masking.
  • Hello dudeami, maybe you had any luck and time preparing the library for us?:)
    not rushing you, just wanted to know. Maybe even if it in development, maybe you have some code on github..? Thanks :)
  • Dudeami, I'm coming back to you with tested code. I'd like your feedback on this gradient_map method. I have it set up for use in core. That's actually great for you if you feel a gradient map method would be welcome. I will have to rework it to be in an extended image class, however I have been working with the image class as well as imagemagick driver to ease up on what I believe has already been a bit of a roundabout experience. Anyway, this makes for easier inclusion into core if a GD non-capable method is considered suitable. A special thanks to @prsjohnny for tracking down some of the Imagemagick issues. Hopefully we can get his config related issue patched. His pull request is here (latest commit): https://github.com/johnnyfreeman/core/commit/9b87142edbbb0e459032262901f0f65829bd2c32. With this I was able to get Imagemagick working. I set debug to true and found out the temp image location was included with the md5 string is truncation. I made a pull request for that: https://github.com/fuel/core/pull/202 Anyway, I have code that is have tested and works with at very least hex, rgb(), and colors by name, like navy, white, etc. If this can be optimized in any way before being submitted as a feature request, then I would appreciate your input. If you want to just take the code for inclusion, then that works just as well for me. Basic sample code for a controller method:
    http://scrp.at/50b24f8a562aba61bc1b324e8370cdeea804f657 Image class method:
    http://scrp.at/2948d38c450b30ea598e852eea4ca2a405620f4e Image driver (handler?):
    http://scrp.at/4130624c8bbecb75ba835e20950c5440d3ef12f6 Imagemagick driver:
    http://scrp.at/6248e4441f1ba910580bbd6ac6856e643d08c203
  • 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.
  • The rounded corners are a good idea, but I'm not entirely sure how masking would be done. Mind giving a little more detail on how you'd like that to work? Edit: Well, my HDD just decided to start crapping out :( I'll see if I can get the library copied over before it decides its done for good. If I can't, I guess I'll just have to rewrite it :S
  • 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.

    If imagelib supports Show-command it would be possible to do like this.
    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();
    }
    

    Relevant Nginx config changes
        location ~* (\.jpg|\.png|\.gif)$ { 
            expires     31d;
    
            try_files $uri @fuel; #Try to read file first and fall back to @fuel php if not found.
        }
    
    

    So you can add use then
    <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.
  • Hey, sorry I havn't gotten it up yet. I've been busy with midterms for college, but I only have one project left and that shouldn't take to long. Anyways, I have a little time to work on it tonight, and I'll try to get it up on github tonight also.
  • no rush dudeami! have a good time at college, make us be proud of you:)))) we know how it is for us programmers :) Once more good luck and keep us posted!
  • 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.

    Hello dudeami, grats on image going to the core!
    Wanted to ask where I can change your latest changes? Would like to check out my earlier bugs. Good idea about reload()... because sometimes we need make many operations based on the 'original' image :) And about gif problems - I'll try to reproduce tonight and post here. Good luck everyone :)
    huglester
  • Heres the github page for it: https://github.com/dudeami/fuel/ Each driver has the same methods, minus masking for imagemagick. The GD version (of masking) is slow though, as it was developed by hand, and is incomplete (Doesn't have anything to handle larger mask than the image itself). Let me know how it works so far, and what changes would improve it :D
  • Hey dudeami, I'll ask one more quesiton, not connected to image lib :) since you are the image guru, I'll try to ask:) I have one problem: http://www.9lessons.info/2010/07/google-like-captcha-with-php.html it is the captcha lib, which creates google-like captcha images. But I needed transparent support, which is not supported :( So I started my own approach, modifying the provided captcha, etc, I ended up with: http://scrp.at/7951c08735cb289025fc7f6c04f750b8ff41a86a - which basically creates transparent bg, etc
    but it adds red color around the captcha text:( http://d.pr/B3M2 . the error is around line 399-403.. if you want to see, what I have changed to make transparent at least somehow to work, just search for: 'if($this->transparent)', and you'll see my 'modified' function etc I will be VERY thankful for any information provided... good luck everyone,
    huglester
  • For the Image Caching, it's possible, but the original intention of the library was just to do the manipulating. For your captcha, Its most likely due to the image being manipulated (GD sucks with transparency :( ). My best bet would be to use a color the captcha will avoid (Such as a magenta) and set it as the background with imagecolortransparent(). That should fix the problem the easiest. Also, I'll do some of my own testing the gif's and see what I come up with :p And thanks for the congrats, I'm happy to give fuel a nice image library :D
  • Hello everyone, to be honest, I find this CI lib very exiting, had no any single problem with it: http://www.matmoo.com/digital-dribble/codeigniter/image_moo/ It has even rounded corners (round()) - but this one requires some recompilation of gd library.. Anyway - other functions are so damn nice! I think it has almost everything we could need (like watermarking, thumb creating, resizing croping etc etc)
  • 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!
  • 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!

    too bad your hdd is dead :( try to keep backups somewhere... it sometimes can save tons of time! not all functions there require the GD recompilation.. so those functions which don't require - I think they could be added... what do you think?
  • Yeah, all the others are good to have, and I will add them. For the round corners, I will try to make them work out of the box. I will try and work on it soon, I got ubuntu installed on a 4GB usb (enough for netbeans and fuel :D). I'll make sure to backup from now on too :p
  • Just wanted to put an update here, as this makes the final GD function finished for the most part. The rounded function currently works for the GD library, and the outcome looks like this (10px diameter): http://i.gfxtub.com/468bbe.png As far as I know, it doesn't require anything special (Works fine on my base WAMP install, haven't tested on my Linux server). At this point its imagemagick functions and some tidying (Function docs, easier to use input, formatting code). Code is on github :)
  • Hello dudeami, thanks for your efforts. Been busy last week, so haven't even touched your code.
    But it looks nice! I think it would reallny nice if you post some code snippets to:
    http://scrp.at/
    while there are no docs etc, so people can start trying etc :) Other than that great job, thank you :)
  • I had some time, and added documentation to all the functions and fixed up a few bugs in the GD library. I'll make up some examples later today, but the function list in the first post should give a good idea on use :p Edit: In my fuel repo, I added an Image class page in the docs/ directory. Has examples for most situations of usage. Edit2: Fixed up the code a bit more, and all the functions are complete for the imagemagick driver. With the test I made in the welcome.php class, it seems to mess up somewhere with the imagemagick driver. Other than that it looks pretty close to being done :)
  • Hello again :) I went threw the library to see if there is an option to set quality like this:
                \Image::load($full_path)
                    ->quality($quality)
                    ->crop_resize($width, $height)
                    ->save($full_path_thumb, 0666);
    

    or maybe:
                \Image::load($full_path)
                    ->crop_resize($width, $height, $quality)
                    ->save($full_path_thumb, 0666);
    

    What do you think about this? I think that would be really nice and sexy usage :)
    But I like the option #1 more than option #2 :) Awaiting comments :)

Howdy, Stranger!

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

In this Discussion