[ https://issues.apache.org/jira/browse/PDFBOX-5787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17827936#comment-17827936 ]
Tilman Hausherr edited comment on PDFBOX-5787 at 3/18/24 11:39 AM: ------------------------------------------------------------------- I don't have a mac so I won't get the exception. All I see is that it happens by converting a CMYK raster to RGB. You could try it yourself by trying to create a raster from scratch: WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height, 4, new Point(0, 0)); and then pass that one to code from toRGBImageAWT: {code} ColorModel colorModel = new ComponentColorModel(colorSpace, false, false, Transparency.OPAQUE, raster.getDataBuffer().getDataType()); BufferedImage src = new BufferedImage(colorModel, raster, false, null); BufferedImage dest = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_RGB); colorConvertOp.filter(src,dest); {code} To get the colorspace, do {{new ICC_ColorSpace(iccProfile)}} on the icc profile [^CGATS001Compat-v2-micro.icc] from PDFBox. To load that one, use ICC_Profile.getInstance() on an inputStream of that file. was (Author: tilman): I don't have a mac so I won't get the exception. All I see is that it happens by converting a CMYK raster to RGB. You could try it yourself by trying to create a raster from scratch: WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height, 4, new Point(0, 0)); and then pass that one to code from toRGBImageAWT: {code} ColorModel colorModel = new ComponentColorModel(colorSpace, false, false, Transparency.OPAQUE, raster.getDataBuffer().getDataType()); BufferedImage src = new BufferedImage(colorModel, raster, false, null); BufferedImage dest = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_RGB); colorConvertOp.filter(src,dest); {code} To get the colorspace, do {{new ICC_ColorSpace(iccProfile)}} on the icc profile [^CGATS001Compat-v2-micro.icc] from PDFBox. To load that one, use ICC_Profile.getInstance() on the input stream. > LCMS error 13: Mismatched alpha channels > ---------------------------------------- > > Key: PDFBOX-5787 > URL: https://issues.apache.org/jira/browse/PDFBOX-5787 > Project: PDFBox > Issue Type: Bug > Components: Rendering > Affects Versions: 3.0.2 PDFBox > Reporter: Niklas > Priority: Major > Attachments: CGATS001Compat-v2-micro.icc > > > Using Kotlin to load the first page and trying to render it as an > `BufferedImage`: > ```kotlin > val pdf = Loader.loadPDF(file) > val preview = PDFRenderer(pdf).renderImage(0, 1.0f) > ``` > with a PDF, I'm running into: > ``` > Exception in thread "main" java.awt.color.CMMException: LCMS error 13: > Mismatched alpha channels > at java.desktop/sun.java2d.cmm.lcms.LCMS.createNativeTransform(Native > Method) > at java.desktop/sun.java2d.cmm.lcms.LCMS.createTransform(LCMS.java:113) > at > java.desktop/sun.java2d.cmm.lcms.LCMSTransform.doTransform(LCMSTransform.java:114) > at > java.desktop/sun.java2d.cmm.lcms.LCMSTransform.colorConvert(LCMSTransform.java:149) > at > java.desktop/java.awt.image.ColorConvertOp.ICCBIFilter(ColorConvertOp.java:350) > at > java.desktop/java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:277) > at > org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGBImageAWT(PDColorSpace.java:375) > at > org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK.toRGBImageAWT(PDDeviceCMYK.java:212) > at > org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK.toRGBImage(PDDeviceCMYK.java:159) > at > org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:506) > at > org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:217) > at > org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:477) > at > org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:438) > at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1106) > at > org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:74) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:893) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:531) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:506) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153) > at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:286) > at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:330) > at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:247) > at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:207) > ``` > Would it be possible to somehow privately share the PDF? It's slightly > sensitive as it is from a customer of mine and I would not want to share it > publicly. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org