Skip navigation
Rob Stevenson
Currently Being Moderated

Image Error

Jul 20, 2012 3:51 PM

Tags: #cf9 #cfimage

All of a sudden we get this error message:

The code worked for several months


 









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




 

WE now added a CFTRY just to keep the page working

 

<cfif XeePV GT 9999>

     <cfset leftaln = 22>

<cfelseif XeePV GT 999>

     <cfset leftaln = 36>

<cfelseif XeePV GT 99>

     <cfset leftaln = 43>

<cfelseif XeePV GT 9>

     <cfset leftaln = 48>

<cfelse>

     <cfset leftaln = 51>

</cfif>

<!--- Create the XeeScore Button on the fly --->

<cftry>

<cfset myImg = ImageNew("http://xeeme.com/_/assets/images/XeePV-Button.png")>

<cfset attr=StructNew()>

<cfset attr.font="Arial">
<cfset attr.size = "50">

<cfset attr.style = "bold">

<cfset ImageDrawText(myImg, "#NumberFormat(XeePV, "_,___")#", #leftaln# ,100,attr) />

<center>

<a class="helpbox" href="##ddXeePV" border="0"><cfimage action="writeToBrowser" source="#myImg#" border="0"></a>

<cfimage source="#myImg#" action="write" destination="#APPLICATION.BaseDir#\_\Data\XeeScore\#session.auth.usr_ ID#.png" overwrite="yes">

</center>

<cfcatch></cfcatch>

</cftry>

 

 

I just can't figure out what the issue is.
The image is there and always have been:
http://xeeme.com/_/assets/images/XeePV-Button.png
http://xeeme.com/_/assets/images/XeePV-Button.png

 

Thanks for any tip

 

Rob

 
Replies
  • Currently Being Moderated
    Jul 20, 2012 6:54 PM   in reply to Rob Stevenson

    Hi XeeMee,

     

    The code below works fine for me (no error, and image is displayed in browser and saved to disk) on CF9.0.1 and CF10:

     

    -----------

    <cfset XeePV = 8>

     

    <cfif XeePV GT 9999>

      <cfset leftaln = 22>

      <cfelseif XeePV GT 999>

      <cfset leftaln = 36>

      <cfelseif XeePV GT 99>

      <cfset leftaln = 43>

      <cfelseif XeePV GT 9>

      <cfset leftaln = 48>

      <cfelse>

      <cfset leftaln = 51>

    </cfif>

     

    <!--- Create the XeeScore Button on the fly --->

    <cfset myImg = ImageNew("http://xeeme.com/_/assets/images/XeePV-Button.png") />

    <cfset attr=StructNew()>

    <cfset attr.font="Arial">

    <cfset attr.size = "50">

    <cfset attr.style = "bold">

    <cfset ImageDrawText(myImg, "#NumberFormat(XeePV, "_,___")#", #leftaln# ,100,attr) />

     

    <center>

      <a class="helpbox" href="#ddXeePV" border="0">

      <cfimage action="writeToBrowser" source="#myImg#" border="0">

      </a>

      <cfimage source="#myImg#" action="write" destination="#expandPath('./foo.png')#" overwrite="yes">

    </center>

    -----------

     

    Couple notes:

    1) Extra # signs can optionally be removed from ImageDrawText(myImg, "#NumberFormat(XeePV, "_,___")#", #leftaln# ,100,attr) and simply become: ImageDrawText(myImg, NumberFormat(XeePV, "_,___"), leftaln ,100,attr)

    2) Creation of the attr struct can optionally be shortened to: <cfset attr = {font="Arial", size=50, style="bold"} />

     

    Thanks,

    -Aaron

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2012 5:20 PM   in reply to Rob Stevenson

    Hi Rob,

     

    Could you try this, and let me know the output when it throws an error?

     

    <cfset myImg = ImageNew("http://xeeme.com/_/assets/images/XeePV-Button.png") />

    <cftry>

      <cfimage action="writeToBrowser" source="#myImg#" border="0">

      <cfcatch>

        <cfoutput>#isImage(myImg)#</cfoutput>

        <cfdump var="#myImg#" />

      </cfcatch>

    </cftry>

     

    Thanks,

    -Aaron

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points