从CFHTTP filecontent将图像转换为使用ColdFusion二进制数据 [英] Convert an image from CFHTTP filecontent to binary data with Coldfusion

查看:132
本文介绍了从CFHTTP filecontent将图像转换为使用ColdFusion二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 CFHTTP 加载到二进制数据的图像(JPG格式)转换。我不能使用 CFFILE ACTION =readBinary,因为它不是一个本地文件。

I'm trying to convert an image (jpg) loaded via cfhttp to binary data. I can't use cffile action="readBinary" as it is not a local file.

推荐答案

下面是我如何处理这个问题,我用它来抓取和处理几百个,每天的图像使用ColdFusion 8。

Here's how I handle this, and I use this to grab and process hundreds of images a day with ColdFusion 8.

<cfhttp
    timeout="45"
    throwonerror="false"
    url="http://domain/image.jpg"
    method="get"
    useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"
    getasbinary="yes"
    result="local.objGet"
>

<cfset local.objImage = ImageNew(local.objGet.FileContent)>

一旦你拥有任何你想用它的图像对象,那么你可以做的。将它保存到磁盘,调整大小,你的名字:)。我明明离开了我所有的错误检查(200状态codeS,它是一个图像等),但这应该让你开始。

Once you have the image object you can then do whatever you want with it. Save it to disk, resize, you name it :). I've obviously left out all of my error checking (200 status codes, is it an image, etc), but this should get you started.

这篇关于从CFHTTP filecontent将图像转换为使用ColdFusion二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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