gd-jpeg: JPEG library reports unrecoverable error 解决办法
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in C:\AppServ\www\mercPhoto.php on line 90
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 'comp_logo/200803171023127332.jpg' is not a valid JPEG file in
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\AppServ\www\mercPhoto.php on line 100
解决见代码。
/**
* 等比例压缩图片
* @param String $src_imagename 源文件名 比如 “source.jpg”
* @param int $maxwidth 压缩后最大宽度
* @param int $maxheight 压缩后最大高度
* @param String $savename 保存的文件名 “d:save”
* @param String $filetype 保存文件的格式 比如 ”.jpg“
* @version 1.0
*/
function resizeImage($src_imagename,$maxwidth,$maxheight,$savename,$filetype)
{ $typeArr=explode(".",$filetype);
$type=$typeArr[];
switch($type)
{
case "png":
$im=imagecreatefrompng($src_imagename);
break; case "jpeg":
$im=imagecreatefromjpeg($src_imagename);
break; case "gif":
$im=imagecreatefromgif($src_imagename);
break;
} $current_width = imagesx($im);
$current_height = imagesy($im); if(($maxwidth && $current_width > $maxwidth) || ($maxheight && $current_height > $maxheight))
{
if($maxwidth && $current_width>$maxwidth)
{
$widthratio = $maxwidth/$current_width;
$resizewidth_tag = true;
} if($maxheight && $current_height>$maxheight)
{
$heightratio = $maxheight/$current_height;
$resizeheight_tag = true;
} if($resizewidth_tag && $resizeheight_tag)
{
if($widthratio<$heightratio)
$ratio = $widthratio;
else
$ratio = $heightratio;
} if($resizewidth_tag && !$resizeheight_tag) $ratio = $widthratio;
if($resizeheight_tag && !$resizewidth_tag)
$ratio = $heightratio; $newwidth = $current_width * $ratio;
$newheight = $current_height * $ratio; if(function_exists("imagecopyresampled"))
{
$newim = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($newim,$im,,,,,$newwidth,$newheight,$current_width,$current_height);
}
else
{
$newim = imagecreate($newwidth,$newheight);
imagecopyresized($newim,$im,,,,,$newwidth,$newheight,$current_width,$current_height);
} $savename = $savename.$filetype;
imagejpeg($newim,$savename);
imagedestroy($newim);
}
else
{
$savename = $savename.$filetype;
imagejpeg($im,$savename);
}
die; }
gd-jpeg: JPEG library reports unrecoverable error 解决办法的更多相关文章
- imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable
错误: imagecreatefromstring(): Empty string or invalid image 或者 imagesx() expects parameter 1 to be re ...
- Eclipse中引入com.sun.image.codec.jpeg包报错的完美解决办法
转: Eclipse中引入com.sun.image.codec.jpeg包报错的完美解决办法 更新时间:2018年02月14日 17:13:03 投稿:wdc 我要评论 Java开发中 ...
- com.sun.image.codec.jpeg在Eclipse中报错的解决办法
在Eclipse中处理图片,需要引入两个包:import com.sun.image.codec.jpeg.JPEGCodec;import com.sun.image.codec.jpeg.JPEG ...
- VMware unrecoverable error解决方法
把开发环境部署在虚拟机里面,重装系统后不须要再反复部署开发环境. 可是有时候异常退出虚拟机会导致错误.之前出现打开虚拟机之后,系统分辨率错误,就是点击的位置和显示的位置不一样. 于是又一次关了虚拟机, ...
- CentOS5/6/7系统下搭建安装Amabari大数据集群时出现SSLError: Failed to connect. Please check openssl library versions.错误的解决办法(图文详解)
不多说,直接上干货! ========================== Creating target directory... ========================== Comman ...
- 全网最详细的启动zkfc进程时,出现INFO zookeeper.ClientCnxn: Opening socket connection to server***/192.168.80.151:2181. Will not attempt to authenticate using SASL (unknown error)解决办法(图文详解)
不多说,直接上干货! at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:) at org ...
- php编译中遇到种种error解决办法
http://my.oschina.net/maczhao/blog/365176 编译PHP5.5 make 时出现错误 make: *** [ext/fileinfo/libmagic/appre ...
- 启动Eclipse弹出:Failed to load JavaHL Library 错误框的解决办法
一.问题背景描述: eclipse安装完svn插件以后,在启动时出现:Failed to load JavaHL Library. These are the errors that were en ...
- Ubuntu 16.04 LTS 下安装MATLAB2015b 以及Matlab system error解决办法
下载MATLAB2015b破解版 操作系统:Ubuntu 16.o4 LTS 程序文件:Matlab2015b-glnxa64破解版 解压提取文件:在ubuntu系统下可以直接提取压缩文件,得到三个文 ...
随机推荐
- 每天一个liunx命令(ubuntu)
解压XXX.gz到另一个A文化夹: 1.切换到root权限 su 2.tar -zxvf XXX.gz -C A 注意: C要大些因为ubuntu区分大小写
- node.js http.get 和http.post 数据
http.get('http://codestudy.sinaapp.com', function (response) {}); node.js http post 样例: var reqData= ...
- Java参数按值传递?按引用传递
有时候在想,java在调用方法时候究竟是按值传递还是按引用传递,之前有人说是基本数据类型按值传递,引用类型按引用传递.一时间,似乎都有道理. 笔者在此不追究字眼上的辨别识字能力,把自己对这个问题的理解 ...
- sql存储过程传入ID集合,和临时表的使用
方式1: Declare @SQL NVarChar(max) set @SQL='select *from Loanee as a ApplicationID in ('+@Application ...
- MapReduce:详解Shuffle过程
Shuffle过程是MapReduce的核心,也被称为奇迹发生的地方.要想理解MapReduce, Shuffle是必须要了解的.我看过很多相关的资料,但每次看完都云里雾里的绕着,很难理清大致的逻辑, ...
- yii2顶部导航使用
yii2中使用顶部导航的具体方法: 1.视图中调用两个类: use yii\bootstrap\Nav;use yii\bootstrap\NavBar; 2. <?php ...
- 【GDI+】 线段 文字 定位的问题(二)
继续: 经过上文的分析,似乎可以得到类似这样的想法: 由此 分为左右两侧进行区分绘制,应该就可以获得想要的结果了~
- Chrome常用快捷键
F2F3 下一个标签 Ctrl+1-9 切换标签 Ctrl+W 关闭 Ctrl+D 保存书签 Ctrl+T 新建书签然后地址栏输入搜索 Ctrl+Shft+T 打开上次关闭 空格 下翻页 Ctrl+J ...
- 在线白板,基于socket.io的多人在线协作工具
首发:个人博客,更新&纠错&回复 是昨天这篇博文留的尾巴,socket.io库的使用练习,成品地址在这里. 代码已经上传到github,传送门.可以开俩浏览器看效果. 现实意义是俩人在 ...
- UINavigationController详解一(转)UIBarButtonItem
本文出自:http://www.cnblogs.com/smileEvday/archive/2012/05/14/2495153.html 特别感谢. 1.UINavigationControlle ...