Interface Encoder

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
GIFEncoder, JPEGEncoder, PNGEncoder, TIFFEncoder

public interface Encoder extends AutoCloseable

Image encoder.

N.B.: Implementations should not obtain encoding options from the application configuration. Instead they should obtain them from the encoding options, which will be pre-populated with all options that are prefixed with Encode.OPTION_PREFIX. Ergo, all option keys used by encoders should start with that prefix.

  • Method Details

    • close

      void close()
      Releases all resources. Must be called when an instance is no longer needed.
      Specified by:
      close in interface AutoCloseable
    • getSupportedFormats

      Set<Format> getSupportedFormats()
      Returns:
      All formats supported by the instance. Note that the implementation must create the instances from scratch and not obtain them from the format registry, which may be empty at the time this method is invoked.
    • setArena

      default void setArena(Arena arena)

      Implementations that make use of the Foreign Function & Memory API should do their native work in this instance. They should not close it.

      The default implementation does nothing.

      Parameters:
      arena - Arena in which to allocate foreign memory.
    • setEncode

      void setEncode(Encode encode)

      Implementations should respect the settings of this instance, including its Metadata.getXMP() XMP metadata}, which they should try to embed, and any relevant encoding options.

      N.B.: Option keys must conform to the syntax described in the documentation of Encode.setOption(String, Object).

      Parameters:
      encode - Instance specifying encoding parameters.
    • encode

      void encode(RenderedImage image, OutputStream outputStream) throws IOException
      Encodes the given image to the given stream.
      Parameters:
      image - Image to write.
      outputStream - Stream to write the image to, which will not be closed.
      Throws:
      IOException
    • encode

      default void encode(BufferedImageSequence sequence, OutputStream outputStream) throws IOException

      Encodes the given image sequence to the given stream.

      The default implementation throws UnsupportedOperationException.

      Parameters:
      sequence - Image sequence to write.
      outputStream - Stream to write the image to, which will not be closed.
      Throws:
      UnsupportedOperationException - if the implementation does not support sequences.
      IOException