ImageNew toBase64编码问题与ColdFusion中的质量损失 [英] ImageNew toBase64 encoding issue with loss of quality in ColdFusion

查看:201
本文介绍了ImageNew toBase64编码问题与ColdFusion中的质量损失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用toBase64()有问题。我希望有人能告诉我为什么CF toBase64()似乎丢失了一些东西,在我的例子,它降低了图像的质量。



我有一个解决方案代码示例如下),但我不讨厌不明白为什么,并希望解决这是CF。



如果任何人都会这么好运行下面的代码,看到afterBase64转换后的图像质量不好。没有什么主要,但它不看起来好编码后。如果你从来没有注意到,然后尝试,你会看到我的意思。



有人知道为什么,或如何在CF中解决这个问题?

 <!--- Example 1 ---> 

<!--- GET IMAGE - --->
< cfset image = ImageNew(test.png)>
<!--- BEFORE GOOD --->
< cfimage action =writeToBrowsersource =#image#>
< cfset image = toBinary(toBase64(image))/>
<!--- AFTER --->
< cfimage action =writeToBrowsersource =#image#>






  <!--- Example 2 ---> 
< cfset image = ImageNew(test.png)>
< cfset FileWrite(expandPath('./ converted.image'),toBinary(toBase64(image)))/>
<!---没有任何cfimage处理,输出的文件是JPEG --->




是使用一个java加载项,一切似乎确定,但由于我不会进入这里,我可以生活的东西。

  image = createObject(java,it.sauronsoftware.base64.Base64)。 
toBinary(image);

以上代码的示例图片输出可以在这里找到: http://i56.tinypic.com/29fwiq.png
首先是在toBase64之前是第二个是之后,可以看到图片有在第二个输出上的toBase64函数后丢失了一点质量。



更新:正如Peter所指出的,问题似乎与ImageObject中的自动输出/转换代码有关,

更新我已将此提交为CF 9.0.1中的错误,请投票支持错误3177303
https://bugbase.adobe.com/index.cfm?event = bug& id = 3177303

解决方案

使用 toBase64(imageGetBlob(myImg))



请参阅: http://blog.dkferguson.com/index.cfm/2010/4/27/All-your-base64-are-not-equal


I have been having problems with toBase64() for awhile. I am hoping someone can tell me why CF toBase64() seems to lost something i.e. in my example it reduces the quality of an image.

I have a solution (see last code example below), but I hate not understanding why and would love to solve this is CF.

If anyone would be so kind to run the code below, you would then see that after toBase64 conversion the image quality is bad. Nothing major, but it does not look as good after the encoding. If you have never noticed, then try it, you will see what I mean.

Does anyone know why, or how to solve this in CF?

<!--- EXAMPLE 1 --->

<!--- GET IMAGE - --->
<cfset image = ImageNew("test.png")>
<!--- BEFORE GOOD--->
<cfimage action="writeToBrowser" source="#image#" >
 <cfset image = toBinary(toBase64(image)) />
 <!--- AFTER --->
<cfimage action="writeToBrowser" source="#image#" >


<!--- Example 2 --->
<cfset image = ImageNew("test.png")>
<cfset FileWrite(expandPath('./converted.image'),toBinary(toBase64(image))) />
<!--- without any cfimage processing, the outputted file is a JPEG --->


My solution was to use a java add-on and everything seemed ok but for reasons I won't go into here not something I can do live.

image = createObject("java","it.sauronsoftware.base64.Base64").encode(image);
 toBinary(image );

Sample image output of code above can be found here: http://i56.tinypic.com/29fwiq.png First is before toBase64 second is after, you can see the image has lost a bit of quality after toBase64 function on the second output.

Update: As pointed out by Peter, the issue seems to be with the automatic output/conversion code within the ImageObject to provide the binary output for the toBase64 function to encode.

Update I have submitted this as a bug in CF 9.0.1, please vote for bug 3177303 https://bugbase.adobe.com/index.cfm?event=bug&id=3177303

解决方案

use toBase64(imageGetBlob(myImg))

see: http://blog.dkferguson.com/index.cfm/2010/4/27/All-your-base64-are-not-equal

这篇关于ImageNew toBase64编码问题与ColdFusion中的质量损失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆