src/Beluga/Drawing/Image/GdImage.php
public final function contractToMaxSize( Size $maxsize, bool $internal = true )
      : IImage
   {

      if ( $maxsize->getWidth()  >= $this->size->getWidth() &&
           $maxsize->getHeight() >= $this->size->getHeight() )
      {
         return $this->returnSelf( $internal );
      }

      $newSize = new Size( $this->size->getWidth(), $this->size->getHeight() );
      $newSize->reduceToMaxSize( $maxsize );

      return $this->createImageAfterResize( $newSize, $internal );

   }
public final function contractToMaxSize( Size $maxsize, bool $internal = true )
      : IImage
   {

      if ( $maxsize->getWidth()  >= $this->size->getWidth() &&
           $maxsize->getHeight() >= $this->size->getHeight() )
      {
         return $this->returnSelf( $internal );
      }

      $newSize = new Size( $this->size->getWidth(), $this->size->getHeight() );
      $newSize->reduceToMaxSize( $maxsize );

      return $this->createImageAfterResize( $newSize, $internal );

   }
public final function contractToMaxSize ( Size $ maxsize , bool $ internal = true ) : IImage { if ( $ maxsize -> getWidth ( ) >= $ this -> size -> getWidth ( ) && $ maxsize -> getHeight ( ) >= $ this -> size -> getHeight ( ) ) { return $ this -> returnSelf ( $ internal ) ; } $ newSize = new Size ( $ this -> size -> getWidth ( ) , $ this -> size -> getHeight ( ) ) ; $ newSize -> reduceToMaxSize ( $ maxsize ) ; return $ this -> createImageAfterResize ( $ newSize , $ internal ) ; }
Reduce the original image size by holding the image size proportion, to fit best the declared
maximum size.

@param  \Beluga\Drawing\Size $maxsize
@param  bool $internal Do not create a new instance?
@return \Beluga\Drawing\Image\IImage
@throws \Beluga\ArgumentError If $maxsize is empty. or bigger than current image
Reduce the original image size by holding the image size proportion to fit best the declared maximum size .