ar.com.hjg.pngj.chunks
Class PngMetadata

java.lang.Object
  extended by ar.com.hjg.pngj.chunks.PngMetadata

public class PngMetadata
extends java.lang.Object

We consider "image metadata" every info inside the image except for the most basic image info (IHDR chunk - ImageInfo class) and the pixels values.

This includes the palette (if present) and all the ancillary chunks

This class provides a wrapper over the collection of chunks of a image (read or to write) and provides some high level methods to access them


Constructor Summary
PngMetadata(ChunksList chunks)
           
 
Method Summary
 double[] getDpi()
          returns -1 if not found or dimension unknown
 PngChunkTIME getTime()
          null if not found
 java.lang.String getTimeAsString()
           
 java.lang.String getTxtForKey(java.lang.String k)
          Returns empty if not found, concatenated (with newlines) if multiple!
 java.util.List<? extends PngChunkTextVar> getTxtsForKey(java.lang.String k)
          gets all text chunks with a given key returns null if not found Warning: this does not check the "lang" key of iTxt
 void queueChunk(PngChunk c)
           
 void queueChunk(PngChunk c, boolean lazyOverwrite)
          Queues the chunk at the writer lazyOverwrite: if true, checks if there is a queued "equivalent" chunk and if so, overwrites it.
 void setDpi(double x)
           
 void setDpi(double x, double y)
           
 PngChunkTextVar setText(java.lang.String k, java.lang.String val)
           
 PngChunkTextVar setText(java.lang.String k, java.lang.String val, boolean useLatin1, boolean compress)
          Creates a text chunk and queue it.
 PngChunkTIME setTimeNow()
           
 PngChunkTIME setTimeNow(int secsAgo)
          Creates a time chunk with current time, less secsAgo seconds
 PngChunkTIME setTimeYMDHMS(int yearx, int monx, int dayx, int hourx, int minx, int secx)
          Creates a time chunk with diven date-time
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PngMetadata

public PngMetadata(ChunksList chunks)
Method Detail

getDpi

public double[] getDpi()
returns -1 if not found or dimension unknown


getTime

public PngChunkTIME getTime()
null if not found


getTimeAsString

public java.lang.String getTimeAsString()

getTxtForKey

public java.lang.String getTxtForKey(java.lang.String k)
Returns empty if not found, concatenated (with newlines) if multiple! - and trimmed

Use getTxtsForKey() if you don't want this behaviour


getTxtsForKey

public java.util.List<? extends PngChunkTextVar> getTxtsForKey(java.lang.String k)
gets all text chunks with a given key

returns null if not found

Warning: this does not check the "lang" key of iTxt


queueChunk

public void queueChunk(PngChunk c)

queueChunk

public void queueChunk(PngChunk c,
                       boolean lazyOverwrite)
Queues the chunk at the writer

lazyOverwrite: if true, checks if there is a queued "equivalent" chunk and if so, overwrites it. However if that not check for already written chunks.


setDpi

public void setDpi(double x)

setDpi

public void setDpi(double x,
                   double y)

setText

public PngChunkTextVar setText(java.lang.String k,
                               java.lang.String val)

setText

public PngChunkTextVar setText(java.lang.String k,
                               java.lang.String val,
                               boolean useLatin1,
                               boolean compress)
Creates a text chunk and queue it.

Parameters:
k - : key (latin1)
val - (arbitrary, should be latin1 if useLatin1)
useLatin1 -
compress -
Returns:
Returns the created-queued chunks, just in case you want to examine, touch it

setTimeNow

public PngChunkTIME setTimeNow()

setTimeNow

public PngChunkTIME setTimeNow(int secsAgo)
Creates a time chunk with current time, less secsAgo seconds

Returns:
Returns the created-queued chunk, just in case you want to examine or modify it

setTimeYMDHMS

public PngChunkTIME setTimeYMDHMS(int yearx,
                                  int monx,
                                  int dayx,
                                  int hourx,
                                  int minx,
                                  int secx)
Creates a time chunk with diven date-time

Returns:
Returns the created-queued chunk, just in case you want to examine or modify it