草庐IT

png_read_info

全部标签

php - 设置ImageMagick PNG图像背景颜色

我有一个PHP脚本来创建PDF文件的PNG缩略图,如下所示:setImageFormat("png");$im->resizeImage(200,200,1,0);//startbufferingob_start();$thumbnail=$im->getImageBlob();$contents=ob_get_contents();ob_end_clean();echo"";?>返回缩略图,但背景是透明的。我想设置白色背景颜色(将alpha层更改为白色)。我该怎么做? 最佳答案 解决方案不在于背景颜色,而在于alphachanne

php - 使用 PHP 调整大小时如何在 PNG 上保持透明背景?

我在使用PHP调整图片大小时遇到​​问题,尤其是具有透明背景的PNG文件,而不是保持透明背景,它变成了黑色背景。我该如何解决这个问题?这是调整大小的脚本:image_type=$image_info[2];if($this->image_type==IMAGETYPE_JPEG){$this->image=imagecreatefromjpeg($filename);}elseif($this->image_type==IMAGETYPE_GIF){$this->image=imagecreatefromgif($filename);}elseif($this->image_type=

php - imagecreatefromstring 使用带有数据 :image/png;base64, 的图像

我将图像存储为以以下内容开头的字符串:data:image/png;base64,我需要将它转换为普通图像以便与GD一起使用。我试过imagecreatefromstring()但它似乎只接受没有data:image/etc前缀的图像。我该怎么办? 最佳答案 $exploded=explode(',',$data,2);//limitto2parts,i.e:findthefirstcomma$encoded=$exploded[1];//pickupthe2ndpart$decoded=base64_decode($encoded

php - 将 .jpg、.jpeg 或 .gif 转换为 .png 而不将它们保存在机器上

是否可以在php中将.jpg、.jpeg或.gif图像转换为.png而无需将图像保存在计算机中?像这样的东西:functionread_image($filename,$extension){switch($extension){case'.png':$image=imagecreatefrompng($filename);break;case'.jpg':case'.jpeg':$unTransformed=imagecreatefromjpeg($filename);$image=transform($unTransformed);break;case'.gif':$unTrans

php - 未捕获的异常 'ImagickException',消息为 'Unable to read the file'

我正在运行带有imagick模块3.1.0RC2的PHP5.4.30。phpinfo()确实将模块显示为已加载,而phpinfo()将PDF显示为受支持的格式。运行时:$image=newImagick();$image->readImage('./test.pdf');我收到:fatalerror:未捕获的异常“ImagickException”和消息“无法读取文件:./test.pdf”当我将图像类型更改为JPEG并读取'./test.jpg'时,未返回任何错误。已检查权限并测试了不同的PDF。我已经插入了图像的绝对路径,但仍然抛出异常。此示例的图像与脚本放在同一目录中。我错过了什

javascript - Google Script 通过电子邮件发送表单值,错误 : cannot read property "namedValues"

项目key:MyvPlY2KvwGODjsi4szfo389owhmw9jII我正在尝试运行一个脚本,该脚本在每次提交表单时通过电子邮件发送我的表单内容。我完全按照下面这个链接中的说明进行操作,直到开始出现错误,并且我收到了更改脚本以按ID打开电子表格的建议:http://www.snipe.net/2013/04/email-contents-google-form/当我完成表格后,它应该将内容通过电子邮件发送到我的电子邮箱。我现在遇到的问题是,通过表单值的函数不起作用。它正在返回错误TypeError:Cannotreadproperty"namedValues"fromundef

nginx - 错误 28105#0 : *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

我无法使用php-fpm正确配置Nginx。当我得到任何php脚本时,我在浏览器中收到Nginx404Notfound错误:Filenotfound.在我的php-fpm日志中我得到:172.17.42.1-28/Apr/2015:09:15:15+0000"GET/index.php"404对于任何php脚本调用和Nginx日志,我得到:[error]28105#0:*1FastCGIsentinstderr:"Primaryscriptunknown"whilereadingresponseheaderfromupstream,client:127.0.0.1,server:loc

javascript - div限制字符的文本,添加 "Read more"链接,点击链接显示所有字符

我有一个使用PHP和MySQL显示的带有文本的div,结构是这样的:Hereisalotoftext.当p标签内的文本超过100个字符时,我想显示“阅读更多”链接。我可以像这样用PHP显示“阅读更多”链接://striptagstoavoidbreakinganyhtml$string=strip_tags($string);if(strlen($string)>100){//truncatestring$stringCut=substr($string,0,100);//makesureitendsinawordsoassassinatedoesn'tbecomeass...$str

php - 为什么 php file_info 为空文本文件返回 inode/x-empty?

我目前正在开发一个包装finfo_file函数的类。以下脚本为所有空文本文件返回inode/x-empty:$finfo=finfo_open(FILEINFO_MIME_TYPE);echofinfo_file($finfo,'/path/to/text_file.txt');在以下环境中测试并收到相同的结果。WAMPWindows7PHP5.4.27Apache2.2.22LinuxUbuntuPHP5.5.10Apache2.4.9我的目标是设置类,以便我可以将文件类型列入白名单。如果text/plain的MIME类型被列入白名单,空文本文件将失败,因为它返回inode/x-em

PHP XML Expat 解析器 : how to read only part of the XML document?

我有一个具有以下结构的XML文档:helloclienttimehelloclienthowcanIhelp?operatortimegoodmorningclienttimegoodmorninghowcanIhelp?operatortime我能够创建解析器并打印出整个文档,但问题是我只想打印(用户)节点和具有特定属性(id)的子节点。我的PHP代码是:if(!empty($_GET['id'])){$id=$_GET['id'];$parser=xml_parser_create();functionstart($parser,$element_name,$element_att