解码器无法解码输入
当用户上传大图像时,使用 cfimage 将图像缩小到尺寸时,我收到此错误。它似乎只抛出较大的图像。较小的可以通过。我在浏览 google/SO 时没有看到对这个问题有太多帮助...
我正在运行 cf8。这是代码,标记失败的行:
<cffile action="move" source="#imgVars.fileData#" destination="#imgVars.folder#\#imgVars.newFileUUID#.#listlast(imgVars.fileName, '.')#" />
<cfset newFile = imgVars.folder & '/' & imgVars.newFileUUID & '.' & listlast(imgVars.filename, '.')>
<cfif fileexists(newFile)>
<cfimage action="read" source="#newFile#" name="imageToUpload"><!---FAILURE--->
<cfif ImageGetHeight(imageToUpload) gt 800 or ImageGetWidth(imageToUpload) gt 600>
<cfset ImageScaleToFit(imageToUpload, 800, 600, "bilinear")>
<cfimage source="#imageToUpload#" action="write" destination="#newFile#" overwrite="yes">
</cfif>
<cfif ImageGetWidth(imageToUpload) gt 600>
<cfset ImageScaleToFit(imageToUpload, 600, 600, "bilinear")>
<cfimage source="#imageToUpload#" action="write" destination="#newFile#" overwrite="yes">
</cfif>
</cfif>
i'm getting this error returned when using cfimage to scale an image down to size when a user uploads a large image. It seems to only throw for larger images. smaller ones go through ok. i've not seen much help for the issue perusing google/SO...
i'm running cf8. here is the code, marking the line it fails:
<cffile action="move" source="#imgVars.fileData#" destination="#imgVars.folder#\#imgVars.newFileUUID#.#listlast(imgVars.fileName, '.')#" />
<cfset newFile = imgVars.folder & '/' & imgVars.newFileUUID & '.' & listlast(imgVars.filename, '.')>
<cfif fileexists(newFile)>
<cfimage action="read" source="#newFile#" name="imageToUpload"><!---FAILURE--->
<cfif ImageGetHeight(imageToUpload) gt 800 or ImageGetWidth(imageToUpload) gt 600>
<cfset ImageScaleToFit(imageToUpload, 800, 600, "bilinear")>
<cfimage source="#imageToUpload#" action="write" destination="#newFile#" overwrite="yes">
</cfif>
<cfif ImageGetWidth(imageToUpload) gt 600>
<cfset ImageScaleToFit(imageToUpload, 600, 600, "bilinear")>
<cfimage source="#imageToUpload#" action="write" destination="#newFile#" overwrite="yes">
</cfif>
</cfif>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
isImageFile()
而不是fileExists()
Try using
isImageFile()
instead offileExists()