草庐IT

png_write_into

全部标签

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 - 如何修复错误 "Fatal error: Uncaught --> Smarty: unable to write file"?

我使用digitalocean将Prestashop从本地主机迁移到网站域,但是当我打开该网站时出现此错误Fatalerror:Uncaught-->Smarty:unabletowritefile/var/www/html/prestashop/cache/smarty/compile/a4/36/f1/wrt549a35e49b3b44_77591243我尝试将smarty文件夹的权限更改为755,但没有成功。我不知道如何修复它。 最佳答案 你的问题肯定是关于权限的。这取决于Apache和PHP的设置方式。首先,检查谁拥有这些文

php - 拉维尔 4 : how to write the correct nested controller for nested resource?

在Laravel4中,我希望创建一组restful资源如下:http://localhost/posts/1/commentshttp://localhost/posts/1/comments/1http://localhost/posts/1/comments/1/edit...所以我创建了两个Controller:PostsController和CommentsController(在同一层),路由写成如下:Route::resource('posts','PostsController');Route::resource('posts.comments','CommentsCon

PHP 银条 ORM : Duplicate key value violates unique constraint for DataObject write

我的网站上有一个功能,可以非常快速地将一堆值保存到相同的DataObject类型。大多数时候没问题,但偶尔会出错ERROR:duplicatekeyvalueviolatesuniqueconstraint...通读我看到的文档:SilverStripedoesnotusethedatabase'sbuilt-inauto-numberingsystem.Instead,itwillgenerateanewIDbyadding1tothecurrentmaximumID之前查看代码,它看起来像是从主键中检索最大数量,插入具有该ID的记录,然后设置DataObject的值并再次写入。在我

php - 如何确保上传的文件是 jpg、gif 或 png?

在php中,我可以通过扩展名检查上传的文件是否具有正确的类型,因此代码应如下所示:if((($_FILES["photo1"]["type"]=="image/gif")||($_FILES["photo1"]["type"]=="image/jpeg")||($_FILES["photo1"]["type"]=="image/png"))&&($_FILES["photo1"]["size"]然后在我的代码的下一步中,我准备了一个文件以供进一步处理。但是,如果有人在上传前将text_file.doc或javascript_file.js更改为samplefile.jpg怎么办?mov

php - 旋转 PNG,然后使用图像透明度重新保存

我在获取正在旋转的PNG上的PNG透明度时遇到了一些重大问题。$filename='bird_up.png';$source=imagecreatefrompng($filename)ordie('Erroropeningfile'.$filename);imagealphablending($source,false);imagesavealpha($source,true);$rotation=imagerotate($source,$degrees,imageColorAllocateAlpha($source,0,0,0,127));imagealphablending($so

php - 如何在 PHP 中通过 Imagick 将 PNG32 转换为 PNG8

我想通过php对象Imagick将PNG32转换为PNG8。但是我用setImageDepth和setImageFormat设置param为8bit,没有生效。代码如下:$im=newImagick($image);$im->cropImage($cutWidth,$cutHeight,$x,$y);$im->thumbnailImage($maxWidth,$maxHeight);$im->setImageDepth(8);$im->setImageFormat('PNG8');$im->writeImage($filename);输入的文件是PNG32,但上面的输出还是PNG8,还

PHP : add write permission to file after move_uploaded_file()

用PHP上传图像后,我想使图像文件可写,以便为其添加水印。以下是我使用的代码:if(isset($_FILES['file_poster']['tmp_name'])&&$_FILES['file_poster']['tmp_name']!=''){$random_filename=substr(md5(time()),0,9);$ext='.jpg';if(strpos(strtolower($_FILES['file_poster']['name']),'.png')>-1){$ext='.png';}move_uploaded_file($_FILES['file_poster'

php - 如何将 Base64 PNG 转换为 JPG 图像?

我有这个Base64PNG,我想将其解码为JPG。如果我转换为PNG,它工作正常,使用:list($type,$data)=explode(';',$data);list(,$data)=explode(',',$data);$data=base64_decode($data);file_put_contents('myDirectory/filename.png',$data);但是如果我尝试将它保存为JPG,它会使用(MyDirectory/filename.jpg)以黑白显示。如何将其转换为JPG?这是我的Base64PNG示例:data:image/png;base64,iVB

php - 如何使用 Imagemagick PHP API 将 .pdf 文件转换为 .png

我想使用ImagemagickphpAPI将.pdf文件转换为.png文件。我们可以在shell中使用这个:$convertsample.pdfsample_image.png我们可以使用phpexec()函数发出此命令,但由于某些原因(安全性)我禁用了使用php执行shell命令。那么现在告诉我如何在不使用phpexec()函数的情况下将我的.pdf文件转换为.png文件的解决方案?关于这个还有另一个讨论here但不是很清楚。 最佳答案 你必须已经安装了php5-imagick$myurl='filename.pdf['.$pag