ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Image Moo - Image manipulation library

July 20, 2010 11:10am

Subscribe [38]
  • #46 / Jun 26, 2011 10:14pm

    ClaudioX

    37 posts

    Anyone knows how output de dinamic_save?

    Between another thing, i try this:

    <img alt='$label'>image_moo->load($image_path)->resize(100,100)->save_dynamic()."'>

    but dont work..

  • #47 / Jun 27, 2011 5:34am

    Mat-Moo

    350 posts

    You can’t do that I’m afraid (Well pretty sure). You will need a callback to your controller that sends the output back e.g. \controlle\sized\image_name and that will output image headers and the resized image.

  • #48 / Jun 27, 2011 7:16pm

    ClaudioX

    37 posts

    Thx the reply Mat!

    So, always when i want to use the dynamic_save i need use somethink like ajax to load the images?

    Thx again, see ya

  • #49 / Jun 27, 2011 7:33pm

    Mat-Moo

    350 posts

    Don’t need ajax jsut “/mycontroller/imagefunction/image_path” although you would have to convert the filepath to something more browser friendly! If you can it’s better to cache the resized image and just serve it direct, that wa the cpu only has to size it once and saves time (disk is cheap!)

  • #50 / Jun 27, 2011 7:39pm

    Mat-Moo

    350 posts

    Great library! =)
    I noticed that it doesn’t support the resize of transparent PNG images at the time so for those who are interested in this, open image_moo.php and look for ( line 552 ):

    // if padding, fill background
    if ($pad)
    {
         $col = $this->_html2rgb($this->background_colour);
         $bg = imagecolorallocate($this->temp_image, $col[0], $col[1], $col[2]);
         imagefilledrectangle($this->temp_image, 0, 0, $tx, $ty, $bg);
    }

    Add the following below:

    imagealphablending($this->temp_image, false);
    imagesavealpha($this->temp_image, true);
    $color = imagecolorallocatealpha($this->temp_image, 0, 0, 0, 127);
    imagefilledrectangle($this->temp_image, 0, 0, $this->width, $this->height, $color);

    That should do it! 😊

    Kind regards,

    Philo

    Where should this be added? after the pad code? I need ot work on keeping transparency data!

  • #51 / Jun 27, 2011 11:24pm

    ClaudioX

    37 posts

    OMG, auhauha, i probably see now, in the image tag put the image_resize uri (controller/func_resizer/image_path)

    To image_path i use:

    public function setSpecialChar($string){
        return str_replace( '=', '', base64_encode( ($string) ) );
    }
    public function getSpecialChar($string){
        return utf8_decode( base64_decode($string) );
    }

    Thx again for all help!

    humm, CI have someway to cache this? for now i dont want create another file..

    “Warning: Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a view.”

    Damn it!

  • #52 / Jun 28, 2011 4:55am

    Mat-Moo

    350 posts

    Caching would write another file anyway 😊

  • #53 / Jul 06, 2011 8:35pm

    Irfan Cikoglu

    38 posts

    Amazing library, thanks.

    Can we use URL for load?

  • #54 / Jul 07, 2011 3:36am

    Mat-Moo

    350 posts

    Not sure, why don’t you try it and let us know.

  • #55 / Jul 07, 2011 11:09am

    Irfan Cikoglu

    38 posts

    It doesn’t works with URL but i fixed. Hope this helps 😊
    Now you can use local image or remote URL for manipulating. 😉

    Download:
    http://pastebin.com/raw.php?i=hTwccqHg

    Usage:

    $this->load->library('image_moo');
        $this->image_moo
            ->load("http://somewebsite.com/someimage.jpg")
            ->resize(200,200)
            ->save("thumb.x");
        if ($this->image_moo->error) print $this->image_moo->display_errors();

    CHANGED: _load_image() function
    ADDED: _check_url() function

    Regards.

  • #56 / Aug 08, 2011 8:13pm

    fatdog

    19 posts

    Great library! =)
    I noticed that it doesn’t support the resize of transparent PNG images at the time so for those who are interested in this, open image_moo.php and look for ( line 552 ):

    // if padding, fill background
    if ($pad)
    {
         $col = $this->_html2rgb($this->background_colour);
         $bg = imagecolorallocate($this->temp_image, $col[0], $col[1], $col[2]);
         imagefilledrectangle($this->temp_image, 0, 0, $tx, $ty, $bg);
    }

    Add the following below:

    imagealphablending($this->temp_image, false);
    imagesavealpha($this->temp_image, true);
    $color = imagecolorallocatealpha($this->temp_image, 0, 0, 0, 127);
    imagefilledrectangle($this->temp_image, 0, 0, $this->width, $this->height, $color);

    That should do it! 😊

    Kind regards,

    Philo

    Where should this be added? after the pad code? I need ot work on keeping transparency data!

    The code goes inside the pad block.
    But this line:

    imagefilledrectangle($this->temp_image, 0, 0, $this->width, $this->height, $color);

    Should be changed to:

    imagefilledrectangle($this->temp_image, 0, 0, $tx, $ty, $color);

    That’s how I made it work

  • #57 / Aug 09, 2011 3:33am

    jedi689

    4 posts

    When I display a png image with save_dynamic

    if the orignal file background is transparent
    its show in black when I display it

    someone know how to fix it?

  • #58 / Aug 10, 2011 12:54am

    nikes

    31 posts

    Cool lib! many thanks quite an ideal offer for sharing

  • #59 / Sep 09, 2011 3:30pm

    Atas

    45 posts

    Hello i changed the method resize to fill with transparent background just in “$pad=true” case.

    //near of line 553…
       //if padding, fill background…
    
            if ($pad)
            {
                $col = $this->_html2rgb($this->background_colour);
                
                if($this->background_colour != ""){
                    $bg = imagecolorallocate($this->temp_image, $col[0], $col[1], $col[2]);
                    imagefilledrectangle($this->temp_image, 0, 0, $tx, $ty, $bg);
                }else{
                    imagecolortransparent ( $this->temp_image ,  imagecolorallocate($this->temp_image, $col[0], $col[1], $col[2]) );
                }
            }


    Now you can do this:

    $this->image_moo
        ->load('DSC01707.JPG')
        ->set_background_colour("#TRANSPARENT")
        ->resize(100,100,TRUE)
        ->save("sarasa.png"); //remember save to png

    what do you think?

  • #60 / Sep 09, 2011 4:05pm

    Mat-Moo

    350 posts

    set_background_color will fail with that. I’ve got to do some further work to improve transparency, but I have got

    if ($pad)
            {
                $col = $this->_html2rgb($this->background_colour);
                $bg = imagecolorallocate($this->temp_image, $col[0], $col[1], $col[2]);
                imagefilledrectangle($this->temp_image, 0, 0, $tx, $ty, $bg);
                /* TO DO
                imagealphablending($this->temp_image, false);
                imagesavealpha($this->temp_image, true);
                $color = imagecolorallocatealpha($this->temp_image, 0, 0, 0, 127);
                imagefilledrectangle($this->temp_image, 0, 0, $this->width, $this->height, $color);
                */
            }

    That might help, can’t remember if it does anything! When I get a spare 5 mins (maybe in 2020) I will do some further work on it!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases