Skip to main content
Inspiring
July 24, 2014
Answered

Problem with CFimage / PNG images

  • July 24, 2014
  • 1 reply
  • 1840 views

I have a problem saving PNG images from another server, for example itunes, some work, some don't

The following image will open fine in my browser ->

http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa367/icon.png

This is the error I am receiving:

An exception occurred while trying to read the image.

javax.imageio.IIOException: Error reading PNG metadata

Code:

<cfimage source="http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa367/icon.png" overwrite="true"  destination="#filepath#/9999.png"

    action = "write">

I believe some images have malformed/incorrect headers. I'm guessing this is a CF issue (I use CF8), because it loads fine in a browser.

Anybody have a solution to this? Maybe an alternative way to retrieve the image? Custom tag?

Thanks

Mark

    This topic has been closed for replies.
    Correct answer ACS LLC

    I found the issue and solution. The problem was with the Java, the JVM had issues reading SOME PNG's from servers, but not all, there must be a newer way of encoding them that was not around when the version of java I had was created, or it's just a bug. I had an earlier version of 1.6 which is downloaded as version SE 6 from Oracle.

    As per some instructions by Ben Forta I tried an update of the JVM to version 7 (1.7.x),

    http://forta.com/blog/index.cfm/2013/3/3/Upgrading-ColdFusion-To-Java-7

    The update worked on my local dev machine which was CF8 with Win 7 64bit, and it actually fixed the CFIMAGE issue!

    However, when I did the same update, with the same java file on the same version of CF8, CF would no longer restart throwing an error that it could not find a file.

    Luckily I had a backup of the config file because I could not switch settings back any other way if CF would not start the administrator (Java also makes a .BAK anyway)

    I tried the first build of version 7, same problem, so I went to the very last version 6, build 45, it installed, and it also fixed the CFIMAGE crash!

    A couple of points for anybody else trying this

    Make sure you have a back up the config, in CF8 it's located here (different to the location in Bens instructions)

    Coldfusion8\runtime\bin\jvm.config

    Also note that the forward and backward slashes are different for the built in JVM that ships with CF and is set in the administrator, and the location you will specify

    Original location: C:/ColdFusion8/runtime/jre

    New location: C:\Program Files\Java\jre7\

    Here is the location to the Java file (

    Java SE Runtime Environment 6u45)

    Java Archive Downloads - Java SE 6

    Took me days to get to the bottom of this, but the fix actually takes just a few simple steps and a few minutes, of course

    Mark

    1 reply

    EddieLotter
    Inspiring
    July 24, 2014

    Some Web sites will not serve images and/or pages without an expected "referrer" HTTP header.

    Are you trying to write a script to automatically download all images in a Web page?

    BKBK
    Community Expert
    July 25, 2014

    Your guess is right. It is probably a CF8 issue. Your code works on Coldfusion 11. Have you installed all the updates and hotfixes for Coldfusion 8?

    An alternative is

    <cfhttp url="http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa367/icon.png"

              method="get"

              getasbinary="yes"

              file="9999.png"

              path="#filepath#" />

    ACS LLCAuthorCorrect answer
    Inspiring
    July 25, 2014

    I found the issue and solution. The problem was with the Java, the JVM had issues reading SOME PNG's from servers, but not all, there must be a newer way of encoding them that was not around when the version of java I had was created, or it's just a bug. I had an earlier version of 1.6 which is downloaded as version SE 6 from Oracle.

    As per some instructions by Ben Forta I tried an update of the JVM to version 7 (1.7.x),

    http://forta.com/blog/index.cfm/2013/3/3/Upgrading-ColdFusion-To-Java-7

    The update worked on my local dev machine which was CF8 with Win 7 64bit, and it actually fixed the CFIMAGE issue!

    However, when I did the same update, with the same java file on the same version of CF8, CF would no longer restart throwing an error that it could not find a file.

    Luckily I had a backup of the config file because I could not switch settings back any other way if CF would not start the administrator (Java also makes a .BAK anyway)

    I tried the first build of version 7, same problem, so I went to the very last version 6, build 45, it installed, and it also fixed the CFIMAGE crash!

    A couple of points for anybody else trying this

    Make sure you have a back up the config, in CF8 it's located here (different to the location in Bens instructions)

    Coldfusion8\runtime\bin\jvm.config

    Also note that the forward and backward slashes are different for the built in JVM that ships with CF and is set in the administrator, and the location you will specify

    Original location: C:/ColdFusion8/runtime/jre

    New location: C:\Program Files\Java\jre7\

    Here is the location to the Java file (

    Java SE Runtime Environment 6u45)

    Java Archive Downloads - Java SE 6

    Took me days to get to the bottom of this, but the fix actually takes just a few simple steps and a few minutes, of course

    Mark