Copy link to clipboard
Copied
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
Thanks for any tip
Rob
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for the notes Aaron. It works well on my local machine - also on our stage server - not on the production server. All are identical CF9.01 Win 2008... I start to believe there is some weakness inside the CFIMAGE Code - there are many similar complaints in the web with no definitive solution. I guess I need to consider it one of those bugs
Copy link to clipboard
Copied
Some more update on this:
This works
<cfimage source="#myImg#" action="write" destination="#APPLICATION.BaseDir#\_\Data\XeeScore\#session.auth.usr_ID#.png" overwrite="yes">
<a class="helpbox" href="##ddXeePV">
<!--- <cfimage action="writeToBrowser" source="#myImg#" border="0"> --->
<IMG SRC="#APPLICATION.BaseSITE#_/Data/XeeScore/#session.auth.usr_ID#.png" border="0">
</a>
If I use CFIMAGE instead of <IMG SRC...> it throws an error
#myimg# is obviously defined and the image is created so it can be read with IMG SRC
But using the simple CFIMAGE writeToBrowser it sais it cant read the image.
Too weired
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi Aaron -
yes, it does throw an error. I extended the test with this code:
<cftry>
<cfset myImg = ImageNew("http://xeeme.com/_/assets/images/XeePV-Button.png") />
<cfcatch>
<cfoutput>
An error happend trying to grab this image:
<IMG src="http://xeeme.com/_/assets/images/XeePV-Button.png"><BR>
<cfset myImg = "http://xeeme.com/_/assets/images/XeePV-Button.png" />
</cfoutput>
</cfcatch>
</cftry>
<cftry>
<cfimage action="writeToBrowser" source="#myImg#" border="0">
<cfcatch>
<cfoutput>#isImage(myImg)#</cfoutput>
<cfdump var="#myImg#" />
</cfcatch>
</cftry>
ERROR: You can see the result on our production server: http://xeeme.com/test/test.cfm Note:CF 9.0.1
Server Product | ColdFusion |
Version | 9,0,1,274733 |
Edition | Standard |
Operating System | Windows Server 2008 R2 |
OS Version | 6.1 |
Adobe Driver Version | 4.0 (Build 0005) |
JVM Details | |
Java Version | 1.6.0_17 |
WORKS FINE: The exact same code on stage: http://stage.xeeme.com/test/test.cfm Note:CF 9.0.0
Server Product | ColdFusion |
Version | 9,0,0,251028 |
Edition | Standard |
Operating System | Windows Server 2008 R2 |
OS Version | 6.1 |
Adobe Driver Version | 4.0 (Build 0005) |
JVM Details | |
Java Version | 1.6.0_17 |
WORKS FINE: local machine again CF 9.0.1
Server Product | ColdFusion |
Version | 9,0,1,274733 |
Edition | Standard |
Operating System | Windows 7 |
OS Version | 6.1 |
Adobe Driver Version | 4.0 (Build 0005) |
JVM Details | |
Java Version | 1.6.0_17 |
Thanks so much for helping here
Rob