我在Lucee for Image Optimization上收到一个非常奇怪的错误,我在Mysql数据库中以BLOB的形式存储图像
所以试着这样做
我在Lucee中得到了一个关于这个代码的错误;
<cfset myImage = imageReadBase64(uploadimage_attachment)>
<cfimage action="write" overwrite="yes" destination="#ExpandPath('optimizeImagesDir/#id#.jpg')#" source="#myImage#">这就是错误:org.apache.commons.imaging.ImageReadException:Can't parse this format.
发布于 2019-03-29 01:55:55
看起来,保存的数据不是有效的图像。您可能需要使用如下insert查询(使用类型为blob的queryparam )。此外,您还需要使用imageGetBlob()将数据转换为BLOB。
<cfset obsolutePathOfImage = "D:/foo.jpg">
<cfset imageVariable = imageRead(obsolutePathOfImage)>
<cfquery datasource="test">
INSERT INTO uploads( myimage )
VALUES ( <cfqueryparam value="#imageGetBlob(imageVariable)#" cfsqltype="cf_sql_blob"> )
</cfquery>最后,为了从BLOB数据创建图像变量,您需要使用imageNew()函数。
<!--- "data" is the name of the query variable & "myimage" is the name of the DB column --->
<cfset filePath = D:/foo_from_DB.jpg>
<cfset myImageVar = imageNew(data.myimage)>
<cfimage action="write" overwrite="yes" destination="#filePath#" source="#myImageVar#">https://stackoverflow.com/questions/55200336
复制相似问题