path) ? $image->origin()->fileExtension() : pathinfo($this->path, PATHINFO_EXTENSION); if ($extension === null || $extension === '') { throw new InvalidArgumentException( 'Unable to extract file extension from path "' . $this->path . '"', ); } return $image->encode( $this->encoderByFileExtension( $extension, ), ); } }