我目前使用 phpthumb 为个人资料图片生成缩略图。http://phpthumb.gxdlabs.com/
这是我目前的方法:
<?php
$path_to_profile_pic = '../icons/default.png';
$profile_pic = file_get_contents('icons/default.png');
$small_profile_pic = PhpThumbFactory::create($profile_pic, array(), true);
$small_profile_pic->adaptiveResize(25, 25);
$small_profile_picAsString = $small_profile_pic->getImageAsString();
?>
<img src="data:image/png;base64,<?php echo base64_encode($small_profile_picAsString); ?>" width="25" height="25" />
但是,由于 base64,这非常慢,因为它会在您的代码中生成大量文本。使用 phpthumb 生成缩略图的最佳方法是什么?
编辑
有没有办法在不保存另一个图像的情况下做到这一点,因为它会占用更多空间?