xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: SOLVED Re: PNG pixel dimensions of given dpi don't correspond to original SVG mm dimensions
Date Wed, 14 May 2008 13:24:22 GMT
Hi Rob,

Rob Davis-5 <tech@robertjdavis.co.uk> wrote on 05/14/2008 08:55:10 AM:

> thomas.deweese wrote:
> > 
> >     Well if I reproduce the math involved I get that the PNG should 
> > contain:
> > 11811 pixels/meter which converts to 299.9994 pixels/inch.  If your 
> > software reports
> > that as 299 then that software is (IMHO) broken. 

> I'm viewing the PNG properties via Windows Explorer - which just shows 
the
> integer part - 299.
> 
> If I view the file in GIMP the properties show more decimal places - 
much
> like your math.
> 
> I'd like to be able to change this to 300 dpi. 

   AFAIK that can't be done.  The PNG specification encode the pixel size 
as
pixels (integer) per meter.  So your two choices are:
        a) 11811 pixels/meter -> 299.9994 dpi
        b) 11812 pixels/meter -> 300.025 dpi

   There is no way to exactly encode 300dpi with PNG.

> Can I get the byte array/stream of the PNG from the transcoder, before 
it is
> written to the file?

   Of course, you pass the output stream that it writes to.  You can use
a ByteArrayOutputStream, or some sort of a pipe processor, but it won't do 
you
any good...

> While I am there, I'll also want to adjust the indexed colors - the 
image is
> black and white BUT 'black' is not totally black, i.e. the RGB values 
aren't
> 00,00,00 yet the original SVG uses the term 'black'.

   What it writes is a pelletized image, it picks the best two (for 1bit) 
_colors_ it can find.  There is no guarantee that they will be black
and white (in fact in many cases they are distinctly not black and white).

   If you really only want black and white I would suggest replacing the
current Batik code as it will do a _lot_ of work to give you a wrong 
(although often close) answer.

> Another way would be to get the PNGTranscoder to give me some sort of
> interface from the JAI (Java Advanced Imaging) so that I could access 
the
> PNG fields that way.

   You are free to read the PNG Batik writes with JAI.  I don't think it's
a good idea to add a dependency on JAI to Batik.

   Good luck.
Mime
View raw message