Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CFIMAGE - Action = info - error when file is BMP

Posted on 2009-04-16
18
Medium Priority
?
1,116 Views
Last Modified: 2013-12-24
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?
0
Comment
Question by:James Rodgers
  • 10
  • 5
  • 2
  • +1
18 Comments
 
LVL 53

Expert Comment

by:_agx_
ID: 24161639
What is the error message ?
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24161744
I had no problems running that code with .bmp files.
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 24161803
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)
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
LVL 53

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 24161843
> <cfimage action="info" structname="imagetemp" source="#sTempExtDir#\#name#">

Cfimage can handle .bmp files.  It may well be a problem with your path or file.

Output the path before the cfimage call.  What is the value of the path #sTempExtDir#\#name#? Verify it actually _is_ a bitmap (ie can you view it with an external program).
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24161860
if you using CF8 you can convert bmp image to jpg
<cfimage source="../cfdocs/images/artgallery/aiden02.bmp" action="convert"
    destination="aiden02.jpg">
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24161891
> 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.
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24161905
also ensure that the file is exist in the directory specified
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 24161956
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
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24162030
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?
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24162035
3.  Can you open any one of those bmp's with an image program (ms paint, etc..)
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 24162134
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
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24162191
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?



0
 
LVL 53

Expert Comment

by:_agx_
ID: 24162219
.. Also, try using ImageNew(..).  Do you get the same results?

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

Author Comment

by:James Rodgers
ID: 24167743
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
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24171720
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

0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24183570
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
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 24224728
>>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
0
 
LVL 53

Expert Comment

by:_agx_
ID: 24225603
> 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.  
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question