Reputation: 10692
I have a piece of code that I am using to verify that an image is valid before attempting to scale it and add it to a PDF. Basically:
<cfset imgPath = "C:\uploads\images\myimage.jpg" />
<cfdump var="#IsImageFile(imgPath)#" />
I have the same image file on both servers and when I run the above code on both servers, one returns "YES", the other returns "NO" ("NO" is correct). Both servers are running ColdFusion 8 (Version 8,0,1,195765). The one returning "NO" is Developer Edition on Windows 7 64-bit, the other is Standard Edition on Windows 2003 SP2 32-bit. I can't see how the OS or Edition would have an effect on a simple piece of code like this. What could be causing this?
Thank you.
Results of Image Test Code:
Developer Edition on Windows 7 (64-bit):
GetReadableImageFormats: BMP,GIF,JFIF,JPEG,JPEG 2000,JPEG-LOSSLESS,JPEG-LS,JPEG2000,JPG,PNG,PNM,RAW,TIF,TIFF,WBMP
GetWriteableImageFormats: BMP,GIF,JFIF,JPEG,JPEG 2000,JPEG-LOSSLESS,JPEG-LS,JPEG2000,JPG,PNG,PNM,RAW,TIF,TIFF,WBMP
FileExists: YES
IsImageFile: NO
Standard Edition on Windows 2003 (32-bit):
GetReadableImageFormats: BMP,GIF,JFIF,JPEG,JPEG 2000,JPEG-LOSSLESS,JPEG-LS,JPEG2000,JPG,PNG,PNM,RAW,TIF,TIFF,WBMP
GetWriteableImageFormats: BMP,GIF,JFIF,JPEG,JPEG 2000,JPEG-LOSSLESS,JPEG-LS,JPEG2000,JPG,PNG,PNM,RAW,TIF,TIFF,WBMP
FileExists: YES
IsImageFile: YES
Upvotes: 0
Views: 231
Reputation: 2138
You might check what version of Java is being used by CF. There may be version differences and one has more features than the other.
Upvotes: 0
Reputation: 2287
I know that this may sound simplistic but if you swap IsImageFile with FileExists, do you get "yes" in both cases?
<cfdump var="#FileExists(imgPath)#" />
Upvotes: 0
Reputation: 3781
Use this function to determine whether an image file is valid. This function returns a False value if the image file format is not supported by the server where ColdFusion is deployed, or if the pathname to the image file is null or invalid.
It goes on to suggest
To determine which image file formats are supported on the server where ColdFusion is deployed, use the GetReadableImageFormats and GetWriteableImageFormats.
I can't see where you've said which server is right and wrong however it seems that the problem is caused by the server rather than CF.
Check the results you get from the get*ImageFormats functions and see if that helps - although reading jpgs is probably baseline...
The other thing to check is the permissions that CF runs under on each server - if you are manually copying the file to the server you may have file access permissions interfering.
Upvotes: 1
Reputation: 1821
Can you attach (or link to) the image here? I'll do the same test on my systems... one Mac and the other Windows 2008.
Upvotes: 0