original_string: public static function scaledFromMedium($medium, $from, $to)
      {
          if (! $medium instanceof ImageMedium) {
              return $medium;
          }
  
          if ($to > $from) {
              return $medium;
          }
  
          $ratio = $to / $from;
          $width = $medium->get('width') * $ratio;
          $height = $medium->get('height') * $ratio;
  
          $prev_basename = $medium->get('basename');
          $basename = str_replace('@'.$from.'x', '@'.$to.'x', $prev_basename);
  
          $debug = $medium->get('debug');
          $medium->set('debug', false);
          $medium->setImagePrettyName($basename);
  
          $file = $medium->resize($width, $height)->path();
  
          $medium->set('debug', $debug);
          $medium->setImagePrettyName($prev_basename);
  
          $size = filesize($file);
  
          $medium = self::fromFile($file);
          if ($medium) {
              $medium->set('size', $size);
          }
  
          return ['file' => $medium, 'size' => $size];
      }
code: public static function scaledFromMedium($medium, $from, $to)
      {
          if (! $medium instanceof ImageMedium) {
              return $medium;
          }
  
          if ($to > $from) {
              return $medium;
          }
  
          $ratio = $to / $from;
          $width = $medium->get('width') * $ratio;
          $height = $medium->get('height') * $ratio;
  
          $prev_basename = $medium->get('basename');
          $basename = str_replace('@'.$from.'x', '@'.$to.'x', $prev_basename);
  
          $debug = $medium->get('debug');
          $medium->set('debug', false);
          $medium->setImagePrettyName($basename);
  
          $file = $medium->resize($width, $height)->path();
  
          $medium->set('debug', $debug);
          $medium->setImagePrettyName($prev_basename);
  
          $size = filesize($file);
  
          $medium = self::fromFile($file);
          if ($medium) {
              $medium->set('size', $size);
          }
  
          return ['file' => $medium, 'size' => $size];
      }
code_tokens: public static function scaledFromMedium ( $ medium , $ from , $ to ) { if ( ! $ medium instanceof ImageMedium ) { return $ medium ; } if ( $ to > $ from ) { return $ medium ; } $ ratio = $ to / $ from ; $ width = $ medium -> get ( 'width' ) * $ ratio ; $ height = $ medium -> get ( 'height' ) * $ ratio ; $ prev_basename = $ medium -> get ( 'basename' ) ; $ basename = str_replace ( '@' . $ from . 'x' , '@' . $ to . 'x' , $ prev_basename ) ; $ debug = $ medium -> get ( 'debug' ) ; $ medium -> set ( 'debug' , false ) ; $ medium -> setImagePrettyName ( $ basename ) ; $ file = $ medium -> resize ( $ width , $ height ) -> path ( ) ; $ medium -> set ( 'debug' , $ debug ) ; $ medium -> setImagePrettyName ( $ prev_basename ) ; $ size = filesize ( $ file ) ; $ medium = self :: fromFile ( $ file ) ; if ( $ medium ) { $ medium -> set ( 'size' , $ size ) ; } return [ 'file' => $ medium , 'size' => $ size ] ; }
docstring: Create a new ImageMedium by scaling another ImageMedium object.
  
  @param  ImageMedium $medium
  @param  int         $from
  @param  int         $to
  @return Medium|array
docstring_tokens: Create a new ImageMedium by scaling another ImageMedium object .