• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problem with CFimage / PNG images

Enthusiast ,
Jul 24, 2014 Jul 24, 2014

Copy link to clipboard

Copied

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

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jul 25, 2014 Jul 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 up

...

Votes

Translate

Translate
Advocate ,
Jul 24, 2014 Jul 24, 2014

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2014 Jul 25, 2014

Copy link to clipboard

Copied

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#" />

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2014 Jul 25, 2014

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2014 Jul 25, 2014

Copy link to clipboard

Copied

Thanks for sharing this result with us. Could you mark it as correct? Cheers.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2014 Jul 25, 2014

Copy link to clipboard

Copied

LATEST

Whoops, I meant to do that... Done

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2014 Jul 25, 2014

Copy link to clipboard

Copied

I actually found the problem and a solution, will post it at the bottom and mark it as the answer

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation