Updated to 0.9.2, fixed a couple of minor bugs :-
Full details and download now at
http://www.matmoo.com/codeigniter/image_moo/
The CI library for image manipulation is great, but I found it awkward to use when doing multiple processes. So I wrote my own library which I’m happy for you to play with and send feedback. It is limited to PHP 5 and GD2 only, sorry, but that suits my needs.
Example :-
$this->load->library('image_moo');
// single thumbnail
$this->image_moo
->load("myfile.x")
->resize(200,200)
->save("thumb.x");
if ($this->image_moo->error) print $this->image_moo->display_errors();
// thumbnail and large, large watermarked
$this->image_moo
->load("myfile.x")
->resize(240,200)
->save("thumb.x")
->resize(1024,768)
->save("medium.x")
->resize(1600,1024)
->save("large.x");
if ($this->image_moo->error) print $this->image_moo->display_errors();
// add watermarks
$this->image_moo
->load("myfile.x")
->load_watermark("image.x")
->resize(240,200)
->save("thumb.x")
->resize(1024,768)
->watermark(2)
->save("medium.x")
->resize(1600,1024)
->watermark(8)
->save("large.x");
if ($this->image_moo->error) print $this->image_moo->display_errors();
// create watermark text
$this->image_moo
->load("myfile.x")
->make_watermark_text("copyright me","font.ttf")
->resize(1024,768)
->watermark(2)
->save("medium.x");
if ($this->image_moo->error) print $this->image_moo->display_errors();Those are a couple of basic uses but it has a couple of extras for resize 😊
resize($max_width,$max_height,$pad=FALSE)
So resize will work as normal, e.g. an image of 1000 x 600. resize(200,200) your output image would be 200 x 120. Sometimes you want this as a square image, so set pad and the returned image will be 200 x 200 and the image centralised on to it. The background colour can be set with $this->image_moo->set_background_colour($html_colour=”#ffffff”) (default is white #ffffff.
There is also another resize, resize_crop($x,$y) which is similar to resize but truncates the original image to get the largest part in the resize. e.g. a 1000 x 600 image resize_crop(200,200) returns a 200 x 200 image, but the source will be the centralised 600 x 600 part of the main image (does that sound right?!)
There are no docs at the moment as this is just version 0.7.2 while I continue the project I need this for, but all feedback is welcome.
——————————————————————————————
load($filename)
Loads a master image in for manipulation
save($filename, $overwrite=FALSE)
Saves the altered image (original if applicable) to file, will only overwrite if $overwrite=TRUE
save_dynamic($filename=”“)
Send the altered image to the screen, use filename to specify how it should be written, default is jpg
load_watermark($filename)
Loads a file to use as a watermark
——————————————————————————————
TBC
Edit : updated to 0.8.9