CI Image Manipulation |
[eluser]phusiondesign[/eluser]
I have been trying to utilize the image manipulation class which is included in code igniter. I keep running into a variety of problems and hope someone can help. The objective is to have a said image and resize / crop it on the fly. I want the image to be resized so that the width is 200px and height doesn't matter at that point... but then I want it chopped off so I only see the top 120px... then displayed. It would be best if a thumb was generated and used every time if it was available instead of running the whole resize / crop script. Code I am using now... I know it is not all there, but I was trying to get something to work. Code: $config['image_library'] = 'GD'; Oh ya, how do I show what I created? Thanks in advance.
[eluser]Référencement Google[/eluser]
I don't specially answer your question, I only put below a function I am using in one application that may help you. It resize an upload picture, then crop it in the middle height at specified dimensions: Code: function resize_crop($files, $path = 'public/gallery')
[eluser]phusiondesign[/eluser]
Thanks for the post... I liked your method, and attempted to adapt it to my quest. Code: $config['image_library'] = 'GD2'; So now I am using this code, and it doesn't generate any errors... but, it doesn't generate a thumb either. I am more confused now. Still seeking help. Thanks!
[eluser]Pygon[/eluser]
Code: $this->image_lib->initialize($config); should be Code: $this->initialize($config); as in the snippet provided by elitemedia
[eluser]phusiondesign[/eluser]
[quote author="Pygon" date="1205283068"] Code: $this->initialize($config); I tried that and received an error (Fatal error: Call to undefined method CI_Loader::initialize()) so I tried the example in the user guide which didn't give an error (http://ellislab.com/codeigniter/user-gui...e_lib.html)... neither work. Any thoughts?
[eluser]Pygon[/eluser]
Bah -- you're right. Quote:$config['image_library'] = 'GD2'; Did you mean 'GD'?
[eluser]Référencement Google[/eluser]
Quote:as in the snippet provided by elitemedia Yes yes, he is right, sorry I just copy and past from my code, but I am using this piece of code in a MY_Image_lib that extend the original one, this is why I don't call $this->image_lib->initialize() functions...
[eluser]Référencement Google[/eluser]
Phusiondesign, you forgot to resize the image before calling the crop: $this->image_lib->resize() If you don't want resize, then in your code you call 2 times the initialize fonction, should be called only once per image work function.
[eluser]phusiondesign[/eluser]
Ok, here is where I am at now. The resize portion is working correctly by itself with the crop part removed, as it creates a thumbnail 200px wide regardless of the height. Check! The new problem is that it is not capturing the new thumbnail. It seems to be cropping the original image, but I have tried to eliminate that possibility. Code: $config['image_library'] = 'GD2';
[eluser]Référencement Google[/eluser]
Quote:It seems to be cropping the original image, but I have tried to eliminate that possibility. This is why I call 2 times in my code the resize function... I know, this is not very intuitive to understand why the Image Lib work like that but It's the only way I have found to make what I wanted. |
Welcome Guest, Not a member yet? Register Sign In |