putting text and image to tiff file

Posted on 2005-04-16
Last Modified: 2013-11-19

  Is there a java class to generate tiff file dynamically?Say i got a set of text and put it on a background image and i want to combine it to tiff file format. Can give me the any link to any website for reference?

thanks in advance.

Question by:sunmaster
    LVL 92

    Expert Comment

    LVL 92

    Accepted Solution

    LVL 15

    Assisted Solution

    Did you try using ImageIO (standard api since 1.4) ? I think it can output a tiff format (Never tried it though)
    LVL 1

    Author Comment


    but is there a simple example?

    LVL 15

    Expert Comment

    Based on the example from javalamanc:

    import java.awt.*;
    import java.awt.image.*;
    import javax.imageio.*;

    public class Main
          public static void main(String st[]) throws Exception
                RenderedImage rendImage = myCreateImage();

                // Write generated image to a file
                try {
                            // Save as Tiff
                      File file = new File("newimage.tiff");
                      ImageIO.write(rendImage, "tiff", file);
                } catch (IOException e) {

          // Returns a generated image.
          public static RenderedImage myCreateImage() {
                int width = 100;
                int height = 100;

                // Create a buffered image in which to draw
                BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

                // Create a graphics contents on the buffered image
                Graphics2D g2d = bufferedImage.createGraphics();

                // Draw graphics
                g2d.fillRect(0, 0, width, height);
                g2d.fillOval(0, 0, width, height);

                // Graphics context no longer needed so dispose it

                return bufferedImage;

    To run it you will need to add to your classpath the jars from:

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    wordsFront challenge 8 49
    bunnyEars challenge 6 47
    HashMap Vs TreeMap 12 34
    for i loop in grovy 1 26
    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now