[MGNLIMG-38] outputting into jpg format fails if processed image is a gif or png Created: 18/May/09  Updated: 02/Apr/13  Resolved: 20/May/09

Status: Closed
Project: Imaging
Component/s: image operations
Affects Version/s: 3.0
Fix Version/s: 3.0

Type: Bug Priority: Major
Reporter: Philipp Bärfuss Assignee: Magnolia International
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
is causing MGNLDAM-85 Displaying a png image fails in some ... Closed
dependency
depends upon MGNLIMG-39 Load operations should create an appr... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

The method ImageUtil.flattenTransparentImageForOpaqueFormat(BufferedImage, OutputFormat) fails for the following cenario
1) input is png and output jpg
2) input is gif and output jpg

the exceptions are not the same

1) java.lang.ClassCastException: java.awt.image.ComponentColorModel cannot be cast to java.awt.image.DirectColorModel

2) java.lang.ArrayIndexOutOfBoundsException: 1
at java.awt.image.PixelInterleavedSampleModel.createSubsetSampleModel(PixelInterleavedSampleModel.java:142)
at sun.awt.image.ByteInterleavedRaster.createWritableChild(ByteInterleavedRaster.java:1279)
at info.magnolia.imaging.util.ImageUtil.flattenTransparentImageForOpaqueFormat(ImageUtil.java:3



 Comments   
Comment by Magnolia International [ 20/May/09 ]

Adding testcases. I get a different exception depending on the source image, it's a transparent gif, I get the same you do; if it's opaque, I get another one.

An opaque png seems to cause no issue; an 8-bit transparent png also throws an ArrayIndexOutOfBoundsException.

A translucent png with alpha channel the ClassCastException you had.

Comment by Magnolia International [ 20/May/09 ]

Solved by fixing MGNLIMG-39

Comment by Christopher Zimmermann [ 24/Jan/13 ]

Explicitly test for ComponentColorModel instead of just catching an exception to determine if fillTransparentPixels should be called.

Generated at Mon Feb 12 02:11:40 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.