2015-11-06 79 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; 
}