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系统下可以直接提取压缩文件,得到三个文 ...
随机推荐
- .net 反编译工具
遇到一个需求,做一个专门访问自己网站的浏览器给用户使用,这个浏览器提供登录功能.此时是一个安装在客户端的exe程序,做登录验证要用到webservice,不能将验证逻辑写入exe中,否则客户端可以利用 ...
- android课程表的实现
//图片下方的码段主要实现了课程表所要显示的基本布局,采用ondraw的方法. //别的内容可以根据自己兴趣添加,下面是本人做的,仅供参考. package com. ...
- paper 25 :SVM支持向量机是什么意思?
转载来源:https://www.zhihu.com/question/21094489 作者:余洋链接:https://www.zhihu.com/question/21094489/answer/ ...
- 关于.Net Remoting 和 Web Servcie的比较
参照文献 http://www.cnblogs.com/shinehouse/articles/3001955.html http://www.cnblogs.com/paper/archive/20 ...
- 为archlinux安装mplayer
很简单的一条命令: pacman -S mplayer 安装完之后是字符界面的,所以你还需要一个图形前端: pacman -S gnome-mplayer
- Angularjs之基本概念梳理(一)
1.Angularjs指令属性ng-app和ng-controller的理解 ng-app指令-标记了AngularJS脚本的作用域,在<html>中添加ng-app属性即说明整个< ...
- IOS程序常用目录
<Home>/AppName.app 应用程序本身包目录 <Home>/Documents/ 应用程序的重要数据文件和用户数据文件等都放在这个目录, iTune ...
- shell 日期加减
shell 日期加减运算 比如今日是2012-04-22 $ date -d "+1 day" +%Y-%m-%d 2012-04-23 $ date -d "- ...
- resultMap / resultType
===================resultMap:实体类的属性和通过resultMap映射后的property属性一致 <resultMap id="workerSelect& ...
- LUA笔记之字符串
LUA提供了自动数值转换, 基本上说是乱来也不为过, 就当做是不熟悉数据结构吧, 例子: print("10" + 1) --> 11 print("10 + 1& ...