-2

I have a file that when I try to convert it will not, but i can convert the file in a online converter. What could be the cause of this?

    FileSeekableStream fss = new FileSeekableStream(tifFile);
    ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", fss, null);
    RenderedImage image = decoder.decodeAsRenderedImage();
    ImageIO.write(image, "png", new File(imageFolder + "/" + baseName + ".png"));

Edit: Trying to be clear about the question, what may cause some tiff files to convert and some not to? What are possible things in a tiff file that I can check to see why it will not convert or things I can change before I try making a tiff to a png?

enter image description here

This is the image

Mason Smith
  • 115
  • 1
  • 15
  • At what stage does it not convert? `decoder`? If so: Open the *tiff* file with *GIMP* or *imageMagic* and check out the details and compatibility with the Java library you are using. *tiff* can have several internal differences causing you not being able to convert. – Norbert Dec 14 '15 at 16:57
  • Is there anyway around this? If say that it is not compatible? Are there other libraries out there that can handle this? – Mason Smith Dec 14 '15 at 18:27
  • Unless you attach a TIFF causing problems (or at the very least tell us what color model and compression etc the file has), you can only have guesses and speculative answers. You haven't even told us if the problem is reading (decoding) or writing. I've written a `TIFFImageReader` plugin for ImageIO that is very capable, but there's now way I can tell if it will solve your problem. – Harald K Dec 14 '15 at 19:41
  • I added the image, and its not throwing any errors or anything it simple just will not write the file I am assuming. – Mason Smith Dec 14 '15 at 21:08

2 Answers2

1

I am not sure what you mean by "cannot convert". I ran into an issue a couple of years ago converting tiff to png - the images converted, but the colors were way off and looked horrible.

The cause was actually that the input image (tifFile) was CMYK and the output file was RGB.

I know its not really an answer, but I am unable to comment here at this point...

Steve O
  • 40
  • 4
  • What i mean is it simple does not write a new file, I had that issue with converting the files to JPG, not PNG, but out of like 250-300 tiff files, 13 will not write as a PNG. – Mason Smith Dec 14 '15 at 18:28
0

I found out that the file that was not converting had a completely different color model than the images that were converting, so I changed the color model of the image that was not converting and it worked, color was off a little but I made progress, thanks for the GIMP suggestion.

Mason Smith
  • 115
  • 1
  • 15