[ 
https://issues.apache.org/jira/browse/BATIK-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18009998#comment-18009998
 ] 

Stanimir Stamenkov commented on BATIK-1383:
-------------------------------------------

[^a117786.jpg] – the {{data:}} URI embedded image in "a117786.svg".

The following reproduces the problem:

{code:java|title=ColorConvertTest.java}
import java.io.File;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import javax.imageio.ImageIO;

public class ColorConvertTest {

    public static void main(String[] args) throws Exception {
        BufferedImage source = ImageIO.read(new File("a117786.jpg"));
        System.out.println(source.getColorModel());
        ColorConvertOp convertOp = new ColorConvertOp(
                ColorSpace.getInstance(ColorSpace.CS_sRGB), null);
        BufferedImage rgb = convertOp.filter(source, null);
        ImageIO.write(rgb, "png", new File("a117786-rgb.png"));
    }

}
{code}

It is generally:

* 
[Any2sRGBRed.java:278-280|https://github.com/apache/xmlgraphics-batik/blob/55478175f635/batik-awt-util/src/main/java/org/apache/batik/ext/awt/image/rendered/Any2sRGBRed.java#L278-L280]

The following, however, appears to work:

{code:java}
    public static void main(String[] args) throws Exception {
        BufferedImage source = ImageIO.read(new File("a117786.jpg"));
        System.out.println(source.getColorModel());
        ColorConvertOp convertOp = new ColorConvertOp(
                source.getColorModel().getColorSpace(), // <--
                ColorSpace.getInstance(ColorSpace.CS_sRGB), null);
        BufferedImage rgb = convertOp.filter(source, null);
        ImageIO.write(rgb, "png", new File("a117786-rgb.png"));
    }
{code}

> Error transcoding specific svgs
> -------------------------------
>
>                 Key: BATIK-1383
>                 URL: https://issues.apache.org/jira/browse/BATIK-1383
>             Project: Batik
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.17
>         Environment: Windows 11
>            Reporter: Melanie Traynor
>            Priority: Major
>         Attachments: 2025-07-21_14-25-35.png, a117786.jpg, a117786.svg, 
> a117926.svg
>
>
> We are using batik to transcode 2 svgs using the PNGTranscoder but it 
> ultimately fails with an error thrown from java.awt.ColorSpace  
> 'java.lang.IllegalArgumentException: Component index out of range: 3'
>  
> I have attached the svgs and the stack trace of the source code at the time 
> of exception.  Please let us know if this is a bug or an issue with the data. 
>  The svgs display successfully in other tools.
> I tried with Batik 1.19 too but get the same issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-h...@xmlgraphics.apache.org

Reply via email to