如何让 ColdFusion 缩放任何类型的图像?
服务器配置:
- Windows Server 2003
- IIS 6
- ColdFusion 8 标准版
- Java Version 6 Update 18 em>
我有一个 ColdFusion 应用程序,允许用户上传将添加到现有 PDF 的图像。将图像添加到 PDF 时,它们必须适合最小/最大高度和宽度,因此需要缩放上传的图像以适合。
例如,假设给定图像的最小高度和宽度为 100x100,最大高度和宽度为 200x200,并且用户上传的图像为 500x1000。我使用下面的逻辑将该图像缩小,而不将图像倾斜(保持其原始形状)至 100x200。对于小于最小值的图像,它将被放大(在上面的示例中,50x50 的图像将被放大到 100x100)。
不幸的是,我遇到了很多用户上传“无效图像”的问题。我知道 ColdFusion 在处理渐进式 JPEG 和 CMYK JPEG 时存在问题,但甚至某些 TIFF 也会抛出错误。此外,3MB TIFF 图像需要一分钟多的时间才能缩放(更不用说所发生的分辨率损失,我已将其作为单独的问题提交这里。)
我添加了逻辑来防止 ColdFusion 尝试使用 IsImageFile()
函数处理“无效图像”,但是当用户遇到图像他们可以在自己的电脑上打开和查看,但我们不能接受。在线打印公司(即Shutterfly、柯达等)是否存在这些问题?我不记得在这些网站上遇到过问题(尽管我知道他们不一定使用 ColdFusion)。
对于如何允许使用更多类型的图像(渐进式、CMYK 等)并提高性能,我有什么想法吗?
Server Config:
- Windows Server 2003
- IIS 6
- ColdFusion 8 Standard Edition
- Java Version 6 Update 18
I have a ColdFusion application that allows users to upload images that will be added to an existing PDF. When the images are added to the PDF, they have to fit within a minimum/maximum height and width, so the uploaded image needs to be scaled to fit.
For instance, let's say the minimum height and width for a given image is 100x100, and the maximum height and width is 200x200, and the user uploads an image that is 500x1000. I use the logic below to scale that image down without skewing the image (it keeps its original shape) to 100x200. For an image smaller than the minimum, it is scaled up (in the example above, a 50x50 image would be scaled up to 100x100).
Unfortunately, I'm running into a lot of problems with users uploading "invalid images". I know that ColdFusion has problems working with Progressive JPEGs and CMYK JPEGs, but even some TIFFs are throwing errors. Also, a 3MB TIFF image takes over a minute to scale (not to mention the loss of resolution that occurs, which I have submitted as a separate question here.)
I've added logic to prevent ColdFusion from trying to process an "invalid image" by using the IsImageFile()
function, but the users are very frustrated when they have an image that they can open and view on their PC, but we can't accept it. Do online print companies (i.e. Shutterfly, Kodak, etc.) have these issues? I can't remember ever having an issue on these websites (though I know they may not necessarily use ColdFusion).
Any thoughts on what I can do to allow more types of images to be used (Progressive, CMYK, etc.) and improve performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能必须使用非 CF 解决方案,就像我们在 CF8 之前所做的那样。这里提到的一些库: https://stackoverflow.com/questions/158756/what -is-the-best-image-manipulation-library
缩放时间在很大程度上取决于您选择使用的算法。在 ColdFusion 中将图像添加到 PDF 充其量是不可预测的。我发现它们经常膨胀,大大增加了 PDF 文件的大小。
以下是文档中的一些信息:
http://livedocs.adobe.com/ Coldfusion/8/htmldocs/help.html?content=functions_in-k_16.html
支持的图像文件格式
cfimage 标签可用于多种不同的文件格式。要列出部署 ColdFusion 应用程序的服务器支持的格式,请使用 GetReadableImageFormats 函数和 GetWriteableImageFormats 函数。
ColdFusion 在 Macintosh、Windows 和 Unix 操作系统上支持以下默认图像格式:
JPEG
GIF
TIFF
PNG
< strong>BMP
ColdFusion 不支持以下图像格式:
动画 GIF
多页 TIFF
PSD
AI
CMYK支持
cfimage 标签支持读取和写入 CMYK 图像,但不支持需要转换图像的操作。例如,您可以将 CMYK 图像与读取、写入、writeToBrowser、调整大小、旋转和信息操作结合使用。您不能将 CMYK 图像与转换、验证码和边框操作一起使用。同样的规则也适用于图像函数。例如,ImageNew、ImageRead 和 ImageWrite 函数支持 CMYK 图像,但 ImageAddBorder 函数不支持。
You will likely have to use a non-CF solution like we had to do before CF8. Some libraries mentioned here: https://stackoverflow.com/questions/158756/what-is-the-best-image-manipulation-library
Scaling time is heavily dependent on the algorithm you chose to use. Adding images to PDFs in ColdFusion is unpredictable at best. I found them to be often inflated, dramatically increasing the PDF file size.
Here is some information from the docs:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_in-k_16.html
Supported image file formats
The cfimage tag operates on a number of different file formats. To list the formats that are supported on the server where the ColdFusion application is deployed, use the GetReadableImageFormats function and the GetWriteableImageFormats function.
ColdFusion supports the following default image formats on Macintosh, Windows, and Unix operating systems:
JPEG
GIF
TIFF
PNG
BMP
ColdFusion does not support the following image formats:
Animated GIF
Multipage TIFF
PSD
AI
CMYK support
The cfimage tag supports reading and writing CMYK images, but does not support actions that require converting the images. For example, you can use CMYK images with the read, write, writeToBrowser, resize, rotate, and info actions. You cannot use CMYK images with the convert, captcha, and border actions. The same rule applies to image functions. For example, the ImageNew, ImageRead, and ImageWrite functions support CMYK images, but the ImageAddBorder function does not.