Python and 16 Bit Tiff
For lossless conversion from 16 bit grayscale TIFF to PNG use PythonMagick: from PythonMagick import Image Image(‘pinei_2002300_1525_modis_ch02.tif’).write(“foo.png”)
For lossless conversion from 16 bit grayscale TIFF to PNG use PythonMagick: from PythonMagick import Image Image(‘pinei_2002300_1525_modis_ch02.tif’).write(“foo.png”)
It’s been a while since the question was asked and I finally find time and a wonderful ordered dither matrix which allows me to give some details on how “icafe” can be used to get similar or better results than calling external ghostscript executable. Some new features were added to “icafe” recently such as better … Read more
Had gone through some study and testing, found a method to convert TIFF to JPEG and sorry for pending so long only uploaded this answer. SeekableStream s = new FileSeekableStream(inFile); TIFFDecodeParam param = null; ImageDecoder dec = ImageCodec.createImageDecoder(“tiff”, s, param); RenderedImage op = dec.decodeAsRenderedImage(0); FileOutputStream fos = new FileOutputStream(otPath); JPEGEncodeParam jpgparam = new JPEGEncodeParam(); jpgparam.setQuality(67); … Read more
The easiest way to read in a TIFF and output a BMP would be to use the ImageIO class: BufferedImage image = ImageIO.read(inputFile); ImageIO.write(image, “bmp”, new File(outputFile)); The only additional thing you would need to do to get this to work is make sure you’ve added the JAI ImageIO JARs to your classpath, since BMP … Read more
Use Imagemagick, or better yet, Ghostscript. http://www.ibm.com/developerworks/library/l-graf2/#N101C2 has an example for imagemagick: convert foo.pdf pages-%03d.tiff http://www.asmail.be/msg0055376363.html has an example for ghostscript: gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -c quit I would install ghostscript and read the man page for gs to see what exact options are needed and experiment.
Start with the first bitmap by putting it into an Image object Bitmap bitmap = (Bitmap)Image.FromFile(file); Save the bitmap to memory as tiff MemoryStream byteStream = new MemoryStream(); bitmap.Save(byteStream, ImageFormat.Tiff); Put Tiff into another Image object Image tiff = Image.FromStream(byteStream) Prepare encoders: var encoderInfo = ImageCodecInfo.GetImageEncoders().First(i => i.MimeType == “image/tiff”); EncoderParameters encoderParams = new EncoderParameters(2); … Read more
First, I downloaded a test TIFF image from this page called a_image.tif. Then I opened with PIL like this: >>> from PIL import Image >>> im = Image.open(‘a_image.tif’) >>> im.show() This showed the rainbow image. To convert to a numpy array, it’s as simple as: >>> import numpy >>> imarray = numpy.array(im) We can see … Read more
This comes down to browser image support; it looks like the only mainstream browser that supports tiff is Safari: http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support Where are you getting the tiff images from? Is it possible for them to be generated in a different format? If you have a static set of images then I’d recommend using something like PaintShop … Read more
If you don’t like or can’t use JAI for any reason I have written a TIFF ImageReader plugin for ImageIO, available on GitHub. It is pure Java and does not need any native installs, and comes with a very friendly open source license (BSD). It supports any baseline TIFF option, along with a lot of … Read more