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]
  • #91 / Aug 23, 2012 2:22pm

    threestate

    7 posts

    is there a limitation on file size when doing resizing?
    I’m having an issue resizing larger images and i am trying to figure out what the w x h ratio should be.

  • #92 / Aug 25, 2012 2:19pm

    Mat-Moo

    350 posts

    That will depends on how much memory you have allocated for PHP processing, the more you have allocated per task the larger the file it can deal with.

  • #93 / Oct 11, 2012 5:30pm

    nunomira

    9 posts

    I’ve had to get the width and height of a resized image, so I added these methods to the Class.
    Does it make sense, or is there a better way to do it?

    public function get_modified_image()
     {
      //----------------------------------------------------------------------------------------------------------
      // returns a resource - the temp (modified) image
      //----------------------------------------------------------------------------------------------------------
      // validate we loaded a main image
      if (!$this->_check_image()) return $this;
      
      // validate we have a temp image
      if (!$this->_check_temp_image()) return $this;
      
      return $this->temp_image;
     }
     
     public function get_modified_image_size()
     {
      //----------------------------------------------------------------------------------------------------------
      // returns an array with the width and heightof the temp (modified) image
      //----------------------------------------------------------------------------------------------------------
      // validate we loaded a main image
      if (!$this->_check_image()) return $this;
      
      // validate we have a temp image
      if (!$this->_check_temp_image()) return $this;
      
      return array('width' => imagesx($this->temp_image), 'height' => imagesy($this->temp_image));
     }
     
     private function _check_temp_image()
     //----------------------------------------------------------------------------------------------------------
     // checks that we have a temp image
     //----------------------------------------------------------------------------------------------------------
     {
      if (!is_resource($this->temp_image))
      {
       $this->set_error("No temp image!");
       return FALSE;
      }
      else
      {
       return TRUE;
      }
     }
  • #94 / Oct 17, 2012 4:05pm

    Mat-Moo

    350 posts

    Makes sense, although my approach would be to have those as class variables, and set them after resize operations etc. e.g. (your code)
    private function _set_new_size()
    //—————————————————————————————————————————————————————
    // Updates the new_widht and height sizes
    //—————————————————————————————————————————————————————
    {
    // just in case
    if ( ! $this->_check_image())
    {
    $this->new_height = 0;
    $this->new_width = 0;
    return;
    }

      // is there a temp image?
      if ( ! is_resource($this->temp_image))
      {
    $this->new_height = $this->height;
    $this->new_width = $this->width;
    return;
    }

      // set new sizes
      $this->new_height = imagesy($this->temp_image);
      $this->new_width = imagesx($this->temp_image);
    }

    then on resize $this->_set_new_size

    I’ve got an updated version if you want, but if yours works then all good 😊

  • #95 / Oct 18, 2012 11:44am

    nunomira

    9 posts

    Hi,
    Thanks for getting back, and thanks for the great Class!

    Yes, your approach, as the creator and maintainer of the Class is better.
    Mine, was the outsider approach!

    Sure, I’m interested in the updated version. I bet everyone is!
    😊

  • #96 / Oct 24, 2012 2:17pm

    hao

    1 posts

    Hi, i want to ask question.
    Sorry for my bad english.

    I have image jpeg 200x120. Ratio(200/120) = 1.666666666666667
    I want resize to 460x290.

    //LINE 508
    if( $this->width > $mw || $this->height > $mh ) {
      if( ($this->width / $this->height) > ($mw / $mh) ) {
        $tnw = $mw;
        $tnh = $tnw * $this->height / $this->width;
      } else {
        $tnh = $mh;
        $tnw = $tnh * $this->width / $this->height;
      }
    }else{
      $tnw = $mw;
      $tnh = $mh;
    }
    
    // CHANGE TO
    
    $ratio = $this->width > $this->height ? ($this->width/$this->height) : ($this->height/$this->width);
    
    if($mw > $mh){
      $tnw = $mw;
      $tnh = floor($mw/$ratio);
    }else{
      $tnw = floor($mh/$ratio);
      $tnh = $mh;
    }

    i change the code little in resize function
    before change, output will be 460x290, ratio not same
    after change, output will be 460x276, ratio same
    other line remain same, i don’t change other line/code

    Problem : using method save, image dimension still 200x120
    but method save_dynamic output 460x276

    i’m using image_moo (v1.0.1), GD2, xampp, windows 7.
    How i can fix that?
    Thanks

  • #97 / Jan 30, 2013 8:43pm

    NikosV

    40 posts

    Hello there Mat.

    Can i use image moo with an external image in a remote server?
    Can i use the save_dynamic() functionallity for that?
    If yes, can you provide me a simple example?

    Thanks in advance,
    Congrats for the great library.

  • #98 / Apr 01, 2013 10:25pm

    Markc

    13 posts

    I have a few questions.

    Is there any new version or plans about releasing new version? 1.0.1 is few years old…

    Does it take to much CPU/RAM resources if on my news portal with 40-50 images per page for every article I use save_dynamic() to dynamically crop the thumbnails? If I use this, how should I keep those thumbnails in cache so it won’t be needed for every visitor to crop the same images again and again?

    I’m really satisfied of the work of the library, but is there something better, some better library that showed in the past years after image_moo that gives better results/performance?

  • #99 / Apr 04, 2013 5:37am

    Markc

    13 posts

    I have a few questions.

    Is there any new version or plans about releasing new version? 1.0.1 is few years old…

    Does it take to much CPU/RAM resources if on my news portal with 40-50 images per page for every article I use save_dynamic() to dynamically crop the thumbnails? If I use this, how should I keep those thumbnails in cache so it won’t be needed for every visitor to crop the same images again and again?

    I’m really satisfied of the work of the library, but is there something better, some better library that showed in the past years after image_moo that gives better results/performance?

    Anyone with anything?

  • #100 / Apr 09, 2013 4:39pm

    Mat-Moo

    350 posts

    1) My testing shows that the ratio all remains and works correct, although there have been several updates since my last post

    2) The library is designed to resize images, you simple save them to another folder and them serve them instead. The library can’t do that as not everyone wants that… about 10 lines of code your end to implement it! Serving images dynamically the way you are will kill your server if the traffic gets too high.

    3) New version available 1.1.5

    Also almost finished the EE plugin for this 😊

  • #101 / Apr 10, 2013 6:48am

    Markc

    13 posts

    1) My testing shows that the ratio all remains and works correct, although there have been several updates since my last post

    2) The library is designed to resize images, you simple save them to another folder and them serve them instead. The library can’t do that as not everyone wants that… about 10 lines of code your end to implement it! Serving images dynamically the way you are will kill your server if the traffic gets too high.

    3) New version available 1.1.5

    Also almost finished the EE plugin for this 😊

    What is the difference between these two?

    get_data_stream($filename=”“)

    save_dynamic($filename=”“)

  • #102 / May 07, 2013 10:31pm

    hebe_210

    8 posts

    thx for your sharing .I just found a image library in C# ,It seems great and I want to program a image viewer.Can this image processing library work ,any suggestions are appreciated.

    thx in advance ,Im a noob

  • #103 / Aug 03, 2013 8:01am

    Volder

    27 posts

    Hello,

    I’m using Image_Moo library and find it very useful. Thanks!

    But I’ve got a question, for all images which are processed by the library (I use cropping basically and adding watermark) I use PageSpeed add-on check in Chrome and I get that all images could be compressed additionally by 10-15% without loss of quality.

    Any idea how it could be improved within the library?

  • #104 / Oct 07, 2013 5:19pm

    newgeek

    1 posts

    I am new and can not make this work ...

    I am trying to upload and image using upload library then use mat-moo to create watermark ..

    here is my code ..

    $config = array(
            'upload_path'   => './uploads/phones/',
            'allowed_types' => 'gif|jpg|png',
            'max_size'      => '2048',
            'max_width'     => '1024',
            'max_height'    => '1024',
            'encrypt_name'  => TRUE,
        );         
           $this->load->library('upload', $config);
           if (!$this->upload->do_upload()) {
        $data['errors'] = $this->upload->display_errors();
           }else{
        $upload_data = $this->upload->data();
           }
        
           $this->load->library('image_moo');
          
           $this->image_moo
           ->load($upload_data['full_path'])
           ->load_watermark("/assets/img/logo.png")
           ->resize(500,440)
           ->watermark(5)
           ->save_dynamic();
           
           print $this->image_moo->display_errors();

    my images are in uploads/phones/ an watermark logo is in /assets/img/logo.png

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

ExpressionEngine News!

#eecms, #events, #releases