Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've got the same problem. With some images, Acrobat failed to display pages with this message: </p> <blockquote> <p>Insufficient data for an image</p> </blockquote> <p><em>My</em> problem came from the colorModel in some jpeg images. To track which images weren't ok, i log the BufferedImage colorModel by <code>log.warn(img.getColorModel());</code></p> <pre><code>[VisualLocatorServlet.doGet:142] ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@4b7fce transparency = 1 has alpha = false isAlphaPre = false [VisualLocatorServlet.doGet:142] ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@4b7fce transparency = 1 has alpha = false isAlphaPre = false [VisualLocatorServlet.doGet:142] ColorModel: #pixelBits = 8 numComponents = 1 color space = java.awt.color.ICC_ColorSpace@19ef899 transparency = 1 has alpha = false isAlphaPre = false </code></pre> <p>Obviously, failing images are 8-bits encoded.</p> <p>To fix that, i did the following:</p> <pre><code>byte[] buffer = null; ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedImage img = ImageIO.read(new URL(visual)); /* resample 8-bits to 24-bits if necessary to fix pdf corruption */ if(img.getColorModel().getNumColorComponents()==1){ log.warn("components #1"+img.getColorModel()); BufferedImage out = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR); Graphics2D g2 = out.createGraphics(); g2.setBackground(Color.WHITE); g2.drawImage(i, 0, 0, null); g2.dispose(); log.warn("redrawn image "+img.getColorModel()); } ImageIO.write(img, "jpeg", out); ... </code></pre> <p>The main point is to recreate a BufferedImage in 24bits. (<code>BufferedImage.TYPE_3BYTE_BGR</code>).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload