2015-11-06 80 views
0

我需要检查两个PFFiles是否在我的云代码中具有相同的图像(像素为像素)。我浏览了“parse-image”的解析文档,并能够将pffiles变成两个Image对象。但是,我不知道如何检查图像是否相同。我想:解析图像比较

var foundIt = false; 
if (image1 === image2) { 
     foundIt = true; 
} 
// foundIt is false 

if (image1.data() === image2.data()) { 
    foundIt = true; 
} 
// foundIt is false (sometimes true, but doesn't match correctly) 

if (image1.toString() === image2.toString()) { 
     foundIt = true; 
} 
// foundIt is false (sometimes true, but doesn't match correctly) 

if (image1.data().toString() === image2.data().toString()) { 
    foundIt = true; 
} 
// foundIt is false (sometimes true, but doesn't match correctly) 

所以没有这些工作时,我与我知道的是相同的,我知道是不相同的图像和图像测试。我试图检查文档,但我没有真正能够找到任何关于如何做到这一点。

+0

的图像是相同的,但在不同时期产生的?如何创建?云代码通常不是这个,你可能需要添加一些第三方代码来帮助你 – Wain

回答

0

曾经有一个Buffer对象可以用来做一些云代码的工作,但是它的文档也从Parse中消失了。在解析图像解析文档中有很少的信息,但我看着它下面的代码可能工作:

if(image1.data().toString("base64") == image2.data().toString("base64")) { 
    foundIt = true; 
}