original_string: private function resizeCropImage(UploadedFile $uploadedFile, $targetFilepath, $width, $height = null, $squared = false)
      {
          try {
              $height = (! empty($height) ? $height : $width);
              $squared = (isset($squared) ? $squared : false);
  
              $image = $this->intervention->make($uploadedFile);
  
              if ($squared) {
                  $width = ($height < $width ? $height : $width);
                  $height = $width;
  
                  $image->fit($width, $height, function ($image) {
                      $image->upsize();
                  });
              } else {
                  $image->resize($width, $height, function ($image) {
                      $image->aspectRatio();
                  });
              }
  
              $image->save($targetFilepath, $this->quality);
  
              // Save to s3
              $s3_url = $this->saveToS3($image, $targetFilepath);
  
              return [
                  'path' => dirname($targetFilepath),
                  'dir' => $this->getRelativePath($targetFilepath),
                  'filename' => pathinfo($targetFilepath, PATHINFO_BASENAME),
                  'filepath' => $targetFilepath,
                  'filedir' => $this->getRelativePath($targetFilepath),
                  's3_url' => $s3_url,
                  'width' => (int) $image->width(),
                  'height' => (int) $image->height(),
                  'filesize' => (int) $image->filesize(),
                  'is_squared' => (bool) $squared,
              ];
          } catch (Exception $e) {
              throw new ImageuploadException($e->getMessage());
          }
      }
code: private function resizeCropImage(UploadedFile $uploadedFile, $targetFilepath, $width, $height = null, $squared = false)
      {
          try {
              $height = (! empty($height) ? $height : $width);
              $squared = (isset($squared) ? $squared : false);
  
              $image = $this->intervention->make($uploadedFile);
  
              if ($squared) {
                  $width = ($height < $width ? $height : $width);
                  $height = $width;
  
                  $image->fit($width, $height, function ($image) {
                      $image->upsize();
                  });
              } else {
                  $image->resize($width, $height, function ($image) {
                      $image->aspectRatio();
                  });
              }
  
              $image->save($targetFilepath, $this->quality);
  
              // Save to s3
              $s3_url = $this->saveToS3($image, $targetFilepath);
  
              return [
                  'path' => dirname($targetFilepath),
                  'dir' => $this->getRelativePath($targetFilepath),
                  'filename' => pathinfo($targetFilepath, PATHINFO_BASENAME),
                  'filepath' => $targetFilepath,
                  'filedir' => $this->getRelativePath($targetFilepath),
                  's3_url' => $s3_url,
                  'width' => (int) $image->width(),
                  'height' => (int) $image->height(),
                  'filesize' => (int) $image->filesize(),
                  'is_squared' => (bool) $squared,
              ];
          } catch (Exception $e) {
              throw new ImageuploadException($e->getMessage());
          }
      }
code_tokens: private function resizeCropImage ( UploadedFile $ uploadedFile , $ targetFilepath , $ width , $ height = null , $ squared = false ) { try { $ height = ( ! empty ( $ height ) ? $ height : $ width ) ; $ squared = ( isset ( $ squared ) ? $ squared : false ) ; $ image = $ this -> intervention -> make ( $ uploadedFile ) ; if ( $ squared ) { $ width = ( $ height < $ width ? $ height : $ width ) ; $ height = $ width ; $ image -> fit ( $ width , $ height , function ( $ image ) { $ image -> upsize ( ) ; } ) ; } else { $ image -> resize ( $ width , $ height , function ( $ image ) { $ image -> aspectRatio ( ) ; } ) ; } $ image -> save ( $ targetFilepath , $ this -> quality ) ; // Save to s3 $ s3_url = $ this -> saveToS3 ( $ image , $ targetFilepath ) ; return [ 'path' => dirname ( $ targetFilepath ) , 'dir' => $ this -> getRelativePath ( $ targetFilepath ) , 'filename' => pathinfo ( $ targetFilepath , PATHINFO_BASENAME ) , 'filepath' => $ targetFilepath , 'filedir' => $ this -> getRelativePath ( $ targetFilepath ) , 's3_url' => $ s3_url , 'width' => ( int ) $ image -> width ( ) , 'height' => ( int ) $ image -> height ( ) , 'filesize' => ( int ) $ image -> filesize ( ) , 'is_squared' => ( bool ) $ squared , ] ; } catch ( Exception $ e ) { throw new ImageuploadException ( $ e -> getMessage ( ) ) ; } }
docstring: Resize file to create thumbnail.
  
  @access private
  @param  UploadedFile $uploadedFile
  @param  string       $targetFilepath
  @param  int          $width
  @param  int          $height         (default: null)
  @param  bool         $squared        (default: false)
  @return array
docstring_tokens: Resize file to create thumbnail .