gpt4 book ai didi

image - 如何使用 CFImage 调整大小并实际减小图像文件大小?

转载 作者:行者123 更新时间:2023-12-01 12:52:21 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why should I resize an image in Coldfusion if the file size doen't decrease and the quality of the image suffers?

我一定是在这里做错了......使用 Coldfuison8

我有一个产品搜索,它从外部服务器中提取图像,因此我需要在运行时设置图像。

假设我有一个 jpg 500x500px 111kb,我正在从外部服务器抓取它。

现在我正在这样做:

<cfimage name="myImage" source="#bildpfad##bilddateiname#" action="read" />
<cfif IsImage(myImage) is true>
<cfscript>
ImageSetAntialiasing(myImage,"on");
variables.breite = 400;
ImageScaleToFit(myImage, variables.breite,"", "highestPerformance");
</cfscript>
<cfxml variable="imageXml">
<cfimage action="writetobrowser" source="#myImage#" />
</cfxml>
<cfoutput><div class="resultsImgWrap">#imageXml#</div></cfoutput>

这可以正常显示图像,但是当我检查文件大小时,我有

400x400px 111.2kB

例如,如果我使用 IrfanView 并仅减小文件大小并保存图像,那么我已经达到 65kb。

问题:如果我正在调整图像大小时,如何让 CFIMAGE 减小文件大小?如果大小保持在 111kb,为什么要使用 CFIMAGE 而不是简单地将图像添加为纯 HTML。

**编辑'':
变量 Bildpfad 和 Bilddateiname 类似于:

bildpfad (path to image):         http://www.some-server.com/images/
bilddateiname (filename): some_image123.jpg

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com