xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <...@jeremias-maerki.ch>
Subject Re: Using PNGEncoder and PNGDecoder
Date Fri, 19 Sep 2008 12:06:19 GMT
I'd recommend you use Image I/O instead. The codecs here are nice for
certain use cases but there are too few people around here to help
maintain and support the code. With Image I/O you have a much bigger
pool of people that can help you if you run into problems. And Image I/O
is also already available to your application if you're using Java 1.4
or later.

On 17.09.2008 06:39:12 Jean-Fran├žois El Fouly wrote:
> Since we use and embed xmlgraphics-commons for the sake of FOP anyway, I 
> tried to use the PNG encoding / decoding classes in another context of 
> our application (thus, not at all related to FOP or Batik).
> In two different places at least we need to write or process (read - 
> process - write) PNG images with their PHYS metadata.
> Since the documentation on using xmlgraphics-commons in general is 
> rather scarce, I tried to figure out myself how to use these classes by 
> reading the code and tried this.
> 
>             PNGDecodeParam decodeParam = new PNGDecodeParam();
>             decodeParam.setGenerateEncodeParam(true);
> 
>             PNGImageDecoder decoder = new PNGImageDecoder(new 
> FileInputStream(sourceFile), decodeParam);
>             RenderedImage srcImage = decoder.decodeAsRenderedImage();
>            
>             // Some irrelevant code removed here
> 
>             BufferedImage dstImage = new 
> BufferedImage(srcImage.getWidth(), srcImage.getHeight(), 
> BufferedImage.TYPE_3BYTE_BGR);
> 
>             // Some processing here...
> 
> 
>             PNGEncodeParam encodeParam = decodeParam.getEncodeParam();
>             System.out.println("Physical dimensions set ?" + 
> encodeParam.isPhysicalDimensionSet());
>             System.out.println("Physical dimensions:" + 
> encodeParam.getPhysicalDimension()[0]);
>             PNGImageEncoder encoder = new PNGImageEncoder(new 
> FileOutputStream(destinationFile), encodeParam);
>             encoder.encode(dstImage);
> 
> Hoping this would propagate the PNG metadata (among which ICCProfile and 
> physical dimensions) from source to destination.
> Well the image processing code works well and the output file is 
> properly encoded, but without any metadata.
> What did I miss in the process ?
> 
> Thanks for helping !
> 
> Jean-Francois
> 
> 
> 



Jeremias Maerki


---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
View raw message