Welcome Guest, Not a member yet? Register   Sign In
Image Moo - Image manipulation library
#71

[eluser]nunomira[/eluser]
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?
Code:
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;
  }
}
#72

[eluser]Mat-Moo[/eluser]
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 Smile
#73

[eluser]nunomira[/eluser]
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!
Smile
#74

[eluser]Unknown[/eluser]
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.

Code:
//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
#75

[eluser]NikosV[/eluser]
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.
#76

[eluser]Markc[/eluser]
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?
#77

[eluser]Markc[/eluser]
[quote author="Markc" date="1364869516"]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?[/quote]

Anyone with anything?
#78

[eluser]Mat-Moo[/eluser]
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 Smile
#79

[eluser]Markc[/eluser]
[quote author="Mat-Moo" date="1365539999"]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 Smile[/quote]

What is the difference between these two?

get_data_stream($filename="")

save_dynamic($filename="")
#80

[eluser]hebe_210[/eluser]
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




Theme © iAndrew 2016 - Forum software by © MyBB