Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 174913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:36:25+00:00 2026-05-11T13:36:25+00:00

I am currently using javax.imageio.ImageIO to write a PNG file. I would like to

  • 0

I am currently using javax.imageio.ImageIO to write a PNG file. I would like to include a tEXt chunk (and indeed any of the chunks listed here), but can see no means of doing so.

By the looks of com.sun.imageio.plugins.png.PNGMetadata it should be possible.

I should be most grateful for any clues or answers.

M.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:36:26+00:00Added an answer on May 11, 2026 at 1:36 pm

    The solution I struck upon after some decompilation, goes as follows …

    RenderedImage image = getMyImage();          Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix( 'png' );  if(!iterator.hasNext()) throw new Error( 'No image writer for PNG' );  ImageWriter imagewriter = iterator.next(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); imagewriter.setOutput( ImageIO.createImageOutputStream( bytes ) );   // Create & populate metadata PNGMetadata metadata = new PNGMetadata(); // see http://www.w3.org/TR/PNG-Chunks.html#C.tEXt for standardized keywords metadata.tEXt_keyword.add( 'Title' ); metadata.tEXt_text.add( 'Mandelbrot' ); metadata.tEXt_keyword.add( 'Comment' ); metadata.tEXt_text.add( '...' ); metadata.tEXt_keyword.add( 'MandelbrotCoords' ); // custom keyword metadata.tEXt_text.add( fractal.getCoords().toString() );             // Render the PNG to memory IIOImage iioImage = new IIOImage( image, null, null ); iioImage.setMetadata( metadata ); // Attach the metadata imagewriter.write( null, iioImage, null ); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using javax.xml.validation.Validator from SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) to perform XSD validation. I would like to
I am currently looking in to some file uploading using Java Server Faces. I've
I'm trying to write a simple lightweight image browser in Java, currently I'm using
I'm currently using the javax.script package for interpreting and executing Javascript code on the
I'm currently writing a javax-usb (JSR-80) implementation using libusb 0.1 as a backend. I
Currently I am using Castor framework to marshall the object into xml file it
Currently, our application uses a javax.mail to send email, using javax.mail.MailMessage. We set the
I'm loading potentially large images using a javax.imageio.ImageReader for thumbnail generation in a GUI,
I am currently using the standard javax.xml.transform library to transform my XML to CSV
I am currently using Java ME to extract Addressbook (ContactList) fields in a device

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.