tags:

views:

21

answers:

1

I'd like to convert (back and forth) the following - PS to TIFF - TIFF to PDF - PDF to TIFF - GIF to TIFF - JPEG to TIFF - TIFF (LZW) to TIFF (CITT G4)

Where, if not specified, TIFF is CITT G4 encoding.

Within embedded code of a Java app; any recommended solutions?

A: 

Java supports many formats out of the box and writing the code to do the conversions is simple and straight forward. PDF is not supported as standard however but there are plenty of libraries out there that will decode it - for instance PDF Box.

You can use ImageIO to read & write many image formats. For example, here is how you might convert between a JPEG and Bitmap.

// Read the JPEG
File input = new File("c:/image.jpg");  
BufferedImage image = ImageIO.read(input);  

// Write the Bitmap
File output = new File("c:/image.bmp");  
ImageIO.write(image, "bmp", output); 

For ImageIO (more specifically and ImageReader / Writer) to recognize a particular image format, there must exist an ImageReaderSPI & ImageWriterSPI registered with the IIOServiceProvider. So, if you want to use ImageIO to read / write unsupported formats such as PDF, you must write your own implementat6ion or download a library that has them. Writing them is pretty easy, I have done so in the past.

S73417H