简体   繁体   English

如何仅使用php来放大从数据库获取的图像的大小

[英]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属性的heightwidth来完成此操作,但我希望仅通过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.

相关问题 如何使用PHP中的while循环和从JavaScript中显示从数据库中获取的多个图像中显示的特定单击图像? - How to display a particular clicked image from multiple image fetched from database using while loop in php, and javascript for displaying? 如何显示使用JSON和PHP从数据库中获取的特定数据 - How to display specific data fetched from database using json with PHP 如何对使用PHP从MySQL数据库获取的记录进行排序? - How to do sorting of records fetched from MySQL database using PHP? 如何使用 ZipArchive 保存 PHP 从 DOCX 获取的图像 - How to save the image fetched from DOCX by PHP using ZipArchive 脚本仅返回从php数据库中获取的第一个值的ID - Script only returns the id of first value fetched from database in php 如何使用fetch函数只获取从数据库中获取的数据的一个值 - How do I get only one value for the data I fetched from database using fetch function 使用PHP创建JSON对象 - 来自数据库列的获取值 - JSON object creation using PHP - from fetched values of database columns 使用PHP从MySQL数据库中获取数据时不显示数据 - Data not displayed when fetched from a MySQL database using PHP 如何打印存储在多维数组中并使用PHP从数据库中获取的数据? - how to print data stored in multidimensional array and fetched from database using PHP? 如何使用下拉菜单对从数据库中获取的php表中的项目进行排序 - How to sort items in php table fetched from database using dropdown menu
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM