Skip to main content
Inspiring
February 10, 2010
Question

CFimage erro

  • February 10, 2010
  • 2 replies
  • 2432 views

Hello,

I just update from CF7 to CF9 standard version and start using cfimage.

<cfset tempPath = "c:/images/#cffile.serverFile#" />
<cfset uploadedImage = "" />
<cfimage action="read" source="#tempPath#" name="uploadedImage"/>
<cfset headingWidth = uploadedImage.GetWidth() />
<cfset headingHeight = uploadedImage.GetHeight() />

I got this error pointing to cfimage line:

Detail

javax.imageio.IIOException:   Can't get input stream from URL!

Message

An   exception occurred while trying to read the image.

Any ideas?

Thanks!

Johnny

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    February 10, 2010

    Is this any better

    <cfset tempPath = cffile.serverDirectory & "\" & cffile.serverFile>          
            <cfimage action="read" source="#tempPath#" name="uploadedImage"/>
            <cfset headingWidth = uploadedImage.GetWidth()>
            <cfset headingHeight = uploadedImage.GetHeight()>

    jfb00Author
    Inspiring
    February 11, 2010

    That works!

    Thanks for you help... looks like sometimes the session variable is blank.

    Regards

    Johnny

    Inspiring
    February 11, 2010

    >> That is an important step in troubleshooting. Even if you think

    >> the file exists, verify it anyway to avoid overlooking possible causes

    Thanks for you help... looks like sometimes the session

    variable is blank.

    Hmm.. there are no session variables in the code you posted. But that is why it is important to post the actual code you are using and to verify all variables and assumptions in your code. I suspect you did not do that, or you probably would have identified the issue sooner But I am glad everything is working for you now.

    Inspiring
    February 10, 2010

    Strange, I would not expect that error from a local file.

    1) Is that the exact code you used or is there other code on the page?

    2) Does the error occur with all images, or just that one?

    3) Did you use FileExists() to verify the image path is valid? ie #tempPath#

    jfb00Author
    Inspiring
    February 10, 2010

    Hello,

    Thanks for you reply and help.

    1. In my path I'm using: <cfset tempPath = "#application.url#/sigs/#cffile.serverFile#" />

    But I check the result and it's fine.

    2. Just for some images, not for all.

    3.Yes, I'm checking for the file before if the file is not there, abort the process.

    Regards


    Johnny

    Inspiring
    February 10, 2010
    1. In my path I'm using: <cfset tempPath = "#application.url#/sigs/#cffile.serverFile#" />

    What is the value of #application.url# ? With the images that fail, does it happen consistently?  If so, can you upload one of them so we can test it.