【发布时间】:2012-06-13 09:00:18
【问题描述】:
我真的不明白为什么 GD 有不同的加载图像的功能,例如:
imagecreatefromjpeg()
imagecreatefrompng()
imagecreatefromgif()
如果图像是字符串则只有一个函数?
imagecreatefromstring()
确实,将图像读入字符串并将其传递给函数要好得多,例如:
$imgBlob = file_get_contents($imagePath);
imagecreatefromstring($imageBlob);
unset($imgBlob); //> Free memory, but I am not interested in memory consumpation
?或者我错过了什么?这可能会给新用户带来潜在的困惑
也许他们只是忘了创建一个函数imageCreateFromFile()?
Ps.当然我对使用file_get_contents方法的内存消耗不感兴趣
【问题讨论】:
-
嗯。公平的问题。这就是你的 PHP 核心库......
-
因为 PHP 在生活中的目标是臃肿充满无用的东西,你可以通过额外的一行轻松完成。