Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5672

PDFToImage might not correctly detect unsupported image formats

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.29, 3.0.0 PDFBox, 4.0.0
    • 2.0.30, 3.0.1 PDFBox, 4.0.0
    • Utilities
    • None
    • Patch

    Description

      PDFToImage contains this code:

              if (getImageFormats().indexOf(imageFormat) == -1)
              {
                  SYSERR.println( "Error: Invalid image format " + imageFormat + " - supported are: " + getImageFormats());
                  return 2;
              }
      

      Here, `getImageFormats()` is called to create a concatenated comma-separated string that contains all supported image formats. The problem is that a simple string search is carried out on the concatenated string. Imagine (hypothetical case) that "jpeg2000" is supported, but "jpeg" is not. If you pass in "jpeg", it will not be detected that the file format is unsupported.
      The solution is to check to formats returned by ImageIO directly. At the same time, the `getImageFormats()`method can be replaced by a simple one-liner.

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            axh Axel Howind
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: