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系统下可以直接提取压缩文件,得到三个文 ...
随机推荐
- 线性表基本维护[ACM]
#include "iostream" #include "string" using namespace std; typedef struct node{ ...
- mysql bin log日志
装mysql,运行一段时间后,在mysql目录下出现一堆类似mysql-bin.000***,从mysql-bin.000001开始一直排列下来,而且占用了大量硬盘空间,高达几十个G. 对于这些超大空 ...
- Hbase HRegionServer启动后自动关闭
突然发现HBASE无法使用了. 然后看到在分布式的情况下,节点上的HRegionServer启动后自动关闭. 同步时间就能解决这个问题. 网上同步时间 1. 安装ntpdate工具 sudo apt ...
- C#下调用C++ SDK的编码常识
一组编码规范,通过C#调用C++ 自动封装的C# SDK,会发现面向对象思想的重要性. C++ SDK可以使用自动封装工具转换成C# SDK.但需要遵守如下规则: 1.如果需要对C#对象进行判断,则分 ...
- html 复习
通过几次修改网页的经历,发现相关基础知识之薄弱,不得不再次花时间复习一遍.希望这是最后一次. 一 通用声明 HTML5 <!DOCTYPE html> HTML 4.01 <!DOC ...
- window7快捷键
新建文件夹:Shift +F10 松手 shift + w 两遍 Enter shift+F Enter
- innodb内部的并发线程
1. innodb_thread_concurrency innodb有一系列的计数器来统计和控制内部的工作线程.其中最重要的一个是innodb_thread_concurrency,和它相关的inn ...
- dojo/dom dojo/domConstruct dojo/query
dom.byId require(["dojo/dom", "dojo/domReady!"], function(dom) { var one = dom.b ...
- HTML5之WebSocket
在HTML5规范中,我最喜欢的Web技术就是正迅速变得流行的WebSocket API.WebSocket提供了一个受欢迎的技术,以替代我们过去几年一直在用的Ajax技术.这个新的API提供了一个方法 ...
- JavaScript:九种弹出对话框
[1.最基本的js弹出对话框窗口代码] 这是最基本的js弹出对话框,其实代码就几句非常简单: <script LANGUAGE="javascript"> <!- ...