[英]how to enlarge the size of an image fetched from database using only php
I want to know is there any inbuilt function in php through which I can display an image greater than the size stored in database(ie greater than the original size). 我想知道php中是否有任何内置函数,通过它我可以显示大于数据库中存储的图像(即大于原始大小)的图像。
I know it can be done using the HTML/CSS properties height
and width
but I want it done through php only. 我知道可以使用HTML / CSS属性的
height
和width
来完成此操作,但我希望仅通过php完成。
I tried imagecreatefromjpeg($filename);
我尝试了
imagecreatefromjpeg($filename);
but it takes file or directory name in place of $filename
and my image is in a database. 但是它将文件名或目录名替换为
$filename
并且我的映像位于数据库中。
Here is a part of my code: 这是我的代码的一部分:
while( $result=mysqli_fetch_array($runquery))
{
echo'<img src="data:image/jpeg;base64,'base64_encode($result['image']).'"/>';
}
Load your image with imagecreatefromstring
. 使用
imagecreatefromstring
加载图像。 Then resize it with imagecopyresized
. 然后使用
imagecopyresized
调整其大小。
Also I would suggest you to only save the paths to your image in the database. 另外,我建议您仅将映像的路径保存在数据库中。
Get Imagick ready and call following function 准备好Imagick并调用以下功能
bool Imagick::setImageExtent ( int $columns , int $rows )
Reference: Imagick::setImageExtent 参考: Imagick :: setImageExtent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.