2011-09-08 41 views
2

讓我只說頂部,我不確定我真的明白cfcontent正在做什麼......所以如果這是一個愚蠢的問題,請耐心等待。從圖像流cfcontent?

我一直在使用cfcontent將我的web根外部的圖像傳輸到瀏覽器。我已經決定,現在我想將圖像存儲在一個變量中,顯示它,有能力修改它,查看這些修改,並且只在我確定我喜歡這些更改時才提交已更改的變量。我在想,我可以用cfcontent以某種方式將變量中的圖像進行流式處理,然後顯示,修改,重新顯示並從變量中保存該圖像。我原來的代碼很乾脆:

<img id="photoPlaceholder" 
    src="/#application.root_name#/administration/PhotoManagement/displayPhoto.cfm?thisImage=#thisImage#" 
    width="500px" /> 

和displayPhoto.cfm包括了:

<cfcontent type = "image/*" 
    file = "myPathName" 
    deleteFile = "No" /> 

我知道我可以讀取該文件到與可變的變量和數據流:

<cffile action="readBinary" file="myPathName" variable="fileObject" /> 
<cfcontent type="image/*" variable="#fileObject#" /> 

但如果我採取中間步驟創建圖像使用

<cfimage source="fileObject" name="myImage" /> 
<cfcontent type="image/*" variable="#myImage#" /> 

然後我得到一個屬性驗證錯誤。

有什麼想法?

回答

4

ImageGetBlob()?

If you think about it - this makes sense. Image variables aren't binary data in ColdFusion. While they may store binary data, ColdFusion wraps up the data in a new "Image" variable type.

http://www.coldfusionjedi.com/index.cfm/2007/9/14/Serving-up-CFIMages-via-Image-Tags-and-a-NonCF-Friday-contest

如果您使用CF9,你可以嘗試將圖像寫入RAM://驅動第一,服務它,然後從RAM中刪除。

+0

嗯..嘗試使用但我得到服務器錯誤,啓動:「NetworkError:500源文件顯示圖像格式。 - http:// localho 「 - 最重要的位是橢圓形的。仍然試圖找出錯誤是什麼。 – earachefl

+0

終於明白了 - 解決方法是直接將圖像讀入cfimage(d'oh!),然後按照中的建議使用ImageGetBlob()。謝謝!!! – earachefl