Link to home
Start Free TrialLog in
Avatar of James Rodgers
James RodgersFlag for Canada

asked on

CFIMAGE - Action = info - error when file is BMP

I am uploading a zip file of images to the server where they are extracted to a temp file and then manipulated in to thumbnails using cfimage and then moved to a permanent location, everything works finer unless one or more of the images is a bmp, if it is a bmp the procressing bombs on this line

<cfimage action="info" structname="imagetemp" source="#sTempExtDir#\#name#">

only happens with bmp's; does not happen with jpg, gif or png

i have wrapped it in a cftry to avoid this issue causing further errors,  but the documentation says cfimage works with bmp files, any one have an idea why this would be causing preoblems?
Avatar of _agx_
_agx_
Flag of United States of America image

What is the error message ?
I had no problems running that code with .bmp files.
Avatar of James Rodgers

ASKER

ColdFusion was unable to create an image from the specified source file.
Ensure that the file is a vaild image file.
 
The error occurred in C:\Inetpub\wwwroot\myrogersrewards\website\ContentAdmin\Media\PhotoGallery\v_UploadPhotoGallery.cfm: line 207
Called from C:\Inetpub\wwwroot\mysite\website\ContentAdmin\Media\PhotoGallery\v_UploadPhotoGallery.cfm: line 204
Called from C:\Inetpub\wwwroot\mysite\website\ContentAdmin\Media\PhotoGallery\v_UploadPhotoGallery.cfm: line 1

205 :       <!--- get current image sizing --->
206 :       
207 :       <cfimage action="info" structname="imagetemp" source="#sTempExtDir#\#name#">
208 :       <!--- create thumbnail --->
209 :       


coldfusion.image.ImageReader$UnableToCreateImageException: ColdFusion was unable to create an image from the specified source file.
      at coldfusion.image.ImageReader.readImage(ImageReader.java:108)
      at coldfusion.image.Image.<init>(Image.java:226)
      at coldfusion.tagext.io.ImageTag.doStartTag(ImageTag.java:414)
      at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2661)
      at cfv_UploadPhotoGallery2ecfm734101774._factor1(C:\Inetpub\wwwroot\mysite\website\ContentAdmin\Media\PhotoGallery\v_UploadPhotoGallery.cfm:207)
      at cfv_UploadPhotoGallery2ecfm734101774._factor3(C:\Inetpub\wwwroot\mysite\website\ContentAdmin\Media\PhotoGallery\v_UploadPhotoGallery.cfm:204)
      at cfv_UploadPhotoGallery2ecfm734101774.runPage(C:\Inetpub\wwwroot\mysite\website\ContentAdmin\Media\PhotoGallery\v_UploadPhotoGallery.cfm:1)
      at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)
      at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370)
      at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you using CF8 you can convert bmp image to jpg
<cfimage source="../cfdocs/images/artgallery/aiden02.bmp" action="convert"
    destination="aiden02.jpg">
> if you using CF8 you can convert bmp image to jpg

If CF does not recognize the file as an image, it probably won't be able to convert it.
also ensure that the file is exist in the directory specified
i output the path and file names being processed, all files are processed until the loop hits a bmp file and then it just dumps the error given

there are about 20 files in the zip package; 5 gif, 6 jpg and the rest bmp, with cftry blocks placed around the image processing block the gif and jpg files are processed and thumbnails are created, without the cftry as soon as the first bmp file is hit the processing stops
Yes, but are the paths for the bmp's valid ... and are the files valid?

1. Do a FileExists to confirm the paths are correct

        <cfoutput>
        DEBUG    BMP Exists:  #FileExists(sTempExtDir &"\"& name)#
        </cfoutput>
       <cfimage action="info" structname="imagetemp" source="#sTempExtDir#\#name#">

2.  If they are valid, can upload one of the bmp's here?
3.  Can you open any one of those bmp's with an image program (ms paint, etc..)
is it possible that the mime type is different among different bmp files; i have had issues with file uploads before where i allowed jpg and a jpg extension file was uploaded and failed, and the mime type was actually jpeg, is this a possiibility? i remember a while a go, been a loooooong time since i used photoshop, there a was such a thing as a windows bitmap vs ??


i also discovered that one of the bmp files cannot be opened, however NO bmp files are being processed
You can double check the mime types, but if you are extracting them from a zip how does that apply here?
http://filext.com/file-extension/BMP

Well, cfimage can handle bmp's.  You can try it yourself.  Create a bmp with ms paint and test it out.  It should work fine, which suggests there is a problem with the fiels themselves.  

Can you upload one of the files?



.. Also, try using ImageNew(..).  Do you get the same results?

<cfset tempImage = ImageNew(sTempExtDir &"\"& name)>
<cfimage action="info" structname="imagetemp" source="#tempImage#">
same thing

any bmp file crashes the system or is ignored when cftry is implemented, one of the files is attached
joomla-error-simplest-forum.bmp
Jester_48,

That is one of the bmp that crashes?  It works perfectly for me (version 8,0,1,195765)

1) Are you sure you verified the file paths are correct
2) What version of CF are you using?
<cfdump var="#server#">
<cfset sTempExtDir = "c:\mydownload">
<cfset name = "joomla-error-simplest-forum.bmp">
<cfset tempImage = ImageNew(sTempExtDir &"\"& name)>
<cfimage action="info" structname="imagetemp" source="#tempImage#">
<cfdump var="#imagetemp#">
 
Results:
=============
struct 
colormodel struct 
alpha_channel_support NO  
alpha_premultiplied NO  
bits_component_1 8  
bits_component_2 8  
bits_component_3 8  
colormodel_type ComponentColorModel  
colorspace Any of the family of RGB color spaces  
num_color_components 3  
num_components 3  
pixel_size 24  
transparency OPAQUE  
 
height 1050  
source c:\mydownload\joomla-error-simplest-forum.bmp  
width 1680  

Open in new window

same same here... your posted .bmp file worked perfectly fine returning full imageinfo structure...

maybe you should post your complete code: uploading a zip file, extracting files from zip, querying the temp folder, running cfimage functions on extracted files... skip any non-relevant code parts like html layouts and such.

the problem must be in file paths or maybe something funny is happening with un-zipping the uploaded archive... what do you use to create the zip file in the first place? how are you un-zipping it?

you may want to cfdump the directory query you run before processing the images and cfabort after it just to make sure the file paths are actually what you think they are - depending on how the files were zipped and how you unzip them you may have a different resulting folder structure from what you think it is...

Azadi
>>That is one of the bmp that crashes?  It works perfectly for me (version 8,0,1,195765)
unfortunately that's the only one i can post, the rst have private information in them i cannot put here, so it just might be those/that particular image(s)

any way this is all moot as the user has now changed the requirements to be jpg only, i will still look in to this, maybe the files are corrupted or are corrupting somehow in either the zip or unzip process

bu to answer some questions
the file paths and names are correct
all the files are extracted to a directory outside the web structure, this allows ANY file to be uploaded a s a zip,  but i am only processing images, so if the user **inadvertently** uploads an exe it cannot be accessed through the web, all the files are in a single directory for a single upload, they are then processed via cfdirectory, cffile and cfimage to be made in to thumbnails in an "album" directory

i made my zip with winzip 11
server side i am using cfzip
> maybe the files are corrupted or are corrupting somehow in either the zip or unzip process

Yes, if you have verified the obvious (ie incorrect file paths) that would seem the most likely explanation.