public static function hydrateImageInfo(ImageInterface $image, $path)
    {
        $imageSize = getimagesize($path);
        $finfo     = new \finfo(FILEINFO_MIME_TYPE);

        $image->setMimeType($finfo->file($path));

        if ($image->getMimeType() == 'text/html') {
            $image->setMimeType('image/svg+xml');
        }

        $image->setExtension((new MimeType)->extensionToMimeType($image->getMimeType()));
        $image->setWeight(filesize($path));
        $image->setWidth($imageSize[0]);
        $image->setHeight($imageSize[1]);

        return $image;
    }
public static function hydrateImageInfo(ImageInterface $image, $path)
    {
        $imageSize = getimagesize($path);
        $finfo     = new \finfo(FILEINFO_MIME_TYPE);

        $image->setMimeType($finfo->file($path));

        if ($image->getMimeType() == 'text/html') {
            $image->setMimeType('image/svg+xml');
        }

        $image->setExtension((new MimeType)->extensionToMimeType($image->getMimeType()));
        $image->setWeight(filesize($path));
        $image->setWidth($imageSize[0]);
        $image->setHeight($imageSize[1]);

        return $image;
    }
public static function hydrateImageInfo ( ImageInterface $ image , $ path ) { $ imageSize = getimagesize ( $ path ) ; $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; $ image -> setMimeType ( $ finfo -> file ( $ path ) ) ; if ( $ image -> getMimeType ( ) == 'text/html' ) { $ image -> setMimeType ( 'image/svg+xml' ) ; } $ image -> setExtension ( ( new MimeType ) -> extensionToMimeType ( $ image -> getMimeType ( ) ) ) ; $ image -> setWeight ( filesize ( $ path ) ) ; $ image -> setWidth ( $ imageSize [ 0 ] ) ; $ image -> setHeight ( $ imageSize [ 1 ] ) ; return $ image ; }
Hydrate image info

@param ImageInterface $image
@param string         $path

@return ImageInterface
Hydrate image info