Uploaded image for project: 'XMLGraphicsCommons'
  1. XMLGraphicsCommons
  2. XGC-99

PNGFile.getImageRawPNG() returns broken image data

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.0.1, 2.6
    • None
    • image codecs
    • None

    Description

      The ImageRawPNG returned by PNGFile.getImageRawPNG() is broken because the provided InputStream (streamVec) contains only part of the raw image data. For a start the magic header is missing, but it's not enough to add it.

      To fix this, I copied the entire stream in the PNGFile constructor like this:

              stream.mark(Integer.MAX_VALUE);
              ByteArrayOutputStream out = new ByteArrayOutputStream();
              IOUtils.copy(stream, out);
              rawStream = new ByteArrayInputStream(out.toByteArray());
              out = null;
              stream.reset();
      

      and use the rawStream in favor of streamVec, which can be removed then.

      Testcases still run successful. This fixes RTF output not working with PNG files in FOP because it checks for (missing) the PNG magic header.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            carsten.pfeiffer Carsten Pfeiffer

            Dates

              Created:
              Updated:

              Slack

                Issue deployment