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]
  • #61 / Sep 09, 2011 4:15pm

    Atas

    45 posts

    if i set_background_colour to #TRANSPARENT the property $this->background_colour returns nothing, for this reason i do ..

    if($this->background_colour != ""){

    works… but it’s a hack…


    Other question:

    Can i set something like master_dim param to fix width and always only resize the height?

    Thank you for this library, it’s great.

    Sorry my english…

  • #62 / Sep 09, 2011 4:21pm

    Mat-Moo

    350 posts

    Yes but $this->image_moo->errors will be true as the _html2rgb routine will fail. Remember that the functions return a reference to self not a result to a function. As for master, just resize with a really large width (9999) that way height will always be used.

  • #63 / Sep 09, 2011 4:38pm

    Atas

    45 posts

    Thank you, works fine!

  • #64 / Oct 03, 2011 12:17pm

    LuCiAn0

    11 posts

    Hi,

    First of all, thank you for this awesome library.  A little correction to the documentation:

    On your example after dealing with the image library, to show any error you use:

    if ($this->image_moo->error) print $this->image_moo->display_errors();

    It should be:

    if ($this->image_moo->errors) print $this->image_moo->display_errors();

    Note the ‘s’ on error

  • #65 / Oct 03, 2011 12:29pm

    LuCiAn0

    11 posts

    BTW, I need a little help:

    I’m using jcrop to send the coordinates to crop the image. It works fine. The problem is that after cropping it I need to resize it to 150, 150.

    He is my crop_thumbnail function:

    function crop_thumbnail($id_artists) {
            $this->load->library('image_moo');
            $this->image_moo
                            ->load($this->input->post('filetocrop'))
                            ->crop($this->input->post('x'), $this->input->post('y'), $this->input->post('x2'), $this->input->post('y2'))
                            ->save_pa("", "_thumb", TRUE);
    
            if ($this->image_moo->errors)
                print $this->image_moo->display_errors();
        }

    If I use:

    $this->image_moo
                            ->load($this->input->post('filetocrop'))
                            ->crop($this->input->post('x'), $this->input->post('y'), $this->input->post('x2'), $this->input->post('y2'))
                            ->resize(150,150),
                            ->save_pa("", "_thumb", TRUE)

    It resizes the orignal image, not the crop.

    My idea was to load another instance of image moo and then resize the new thumb file, but since I’m using save_pa and appending ‘_thumb’ to the file, how to retrieve the new thumb file name before resizing it? Is there any easy way to get the new thumb file name? Or I would need a regex to take the extension out then add_thumb to the name and concatenate with the extension again?

    Thanks

     

  • #66 / Oct 03, 2011 5:47pm

    Mat-Moo

    350 posts

    Thanks for the errors catch.

    public function load_temp()
     //----------------------------------------------------------------------------------------------------------
     // Take the temp image and make it the main image
     //----------------------------------------------------------------------------------------------------------
     {
      // validate we loaded a main image
      if (!$this->_check_image()) return $this;
    
      if (!is_resource($this->temp_image))
      {
       $this->set_error("No temp image created!");
       return FALSE;
      }
    
      $this->main_image = $this->temp_image;
      $this->width = imageSX($this->main_image);
      $this->height = imageSY($this->main_image);
      $this->clear_temp();
    
      // return the object
      return $this;
     }

    try adding the above (untested)
    then

    $this->image_moo
                            ->load($this->input->post('filetocrop'))
                            ->crop($this->input->post('x'), $this->input->post('y'), $this->input->post('x2'), $this->input->post('y2'))
                            ->load_temp()
                            ->resize(150,150),
                            ->save_pa("", "_thumb", TRUE)

    It should in theory replace the main loaded image, with your cropped image, then resize as normal.

  • #67 / Oct 03, 2011 5:57pm

    LuCiAn0

    11 posts

    Thank for your reply. But, unfortunately it didn’t work.

    Getting No main image loaded! error

    Thanks,

  • #68 / Oct 03, 2011 6:06pm

    Mat-Moo

    350 posts

    $this->image_moo
                            ->load($this->input->post('filetocrop'))
                            ->save_pa("", "_thumb", TRUE);

    Does that work at all? I would of thought you would of needed to process the upload, save it as a temp file and load the temp file (e.g. look at the upload helper)

  • #69 / Oct 03, 2011 6:15pm

    LuCiAn0

    11 posts

    $this->image_moo
                            ->load($this->input->post('filetocrop'))
                            ->save_pa("", "_thumb", TRUE);

    This works fine. I had thought on the same suggestion you provided. I was just wondering if there was anything like that built in into image_moo library. No big deal though.

    Thank you very much

  • #70 / Oct 16, 2011 4:25pm

    RS71

    106 posts

    I’d like to have an image have a set width (to fill a column width) but a max height - if height exceeds, do a resize_crop using set width and max height. Can this library easily do this?

    Cheers

  • #71 / Oct 17, 2011 4:12am

    Mat-Moo

    350 posts

    Resize_crop should work from memory (Sorry not got the code with me)

  • #72 / Oct 20, 2011 6:34pm

    jellysandwich

    19 posts

    Is there any way to convert all images to jpg?

  • #73 / Oct 21, 2011 4:10am

    Mat-Moo

    350 posts

    Just save with a new .jpg filename and it should convert for you.

  • #74 / Oct 23, 2011 10:20am

    skcin7

    17 posts

    The CI library for image manipulation is great, but I found it awkward to use when doing multiple processes.

    You aren’t kidding about CI’s image_lib library being awkward to use, including and ESPECIALLY for multiple processes. I just spent the last few days trying to do exactly what your resize_crop function does in the image_moo library. I still was not able to figure it out…... and then I found your library and it worked instantly…. thank you sooooo much for writing that awesome image library and providing it to the community. 😊

  • #75 / Oct 23, 2011 4:59pm

    RS71

    106 posts

    I’d like to have an image have a set width (to fill a column width) but a max height - if height exceeds, do a resize_crop using set width and max height. Can this library easily do this?

    Cheers

    Resize_crop should work from memory (Sorry not got the code with me)

    I don’t think resize_crop does it - I believe it is expanding the image to fit dimensions while center cropping it. If so, is there anyway you could implement this?

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

ExpressionEngine News!

#eecms, #events, #releases