Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.0.29, 3.0.0 PDFBox, 4.0.0
-
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.