php gd imagecreatefromstring()和图像mime类型

Mar*_*cin 5 php gd mime-types

有没有办法使用imagecreatefromstring()和得到什么是图像类型?

Bue*_*ler 3

当您使用 imagecreatefrom... 方法时,图像将作为未压缩的位图加载到内存中。此时还没有真正的图像类型。您可以使用 image... 功能将其保存为您想要的任何类型。

$img = imagecreatefromstring($data);

imagepng($img, "file path and name");

imagedestroy($img);
Run Code Online (Sandbox Code Playgroud)

https://www.php.net/manual/en/function.imagecreatefromstring.php