public void storeImage(TiledImage img, String filepath) { TIFFEncodeParam tep = new TIFFEncodeParam(); //important to avoid OutOfMemory tep.setTileSize(256, 256); tep.setWriteTiled(true); //fast compression tep.setCompression(TIFFEncodeParam.COMPRESSION_PACKBITS); //write file JAI.create("filestore", img, filepath, "TIFF", tep); }
TIFFEncodeParam param = new TIFFEncodeParam(); TIFFField tf = td.getField(259); // Compression as specified in the input file param.setCompression(tf.getAsInt(0)); // Set the compression of the output to be the same. param.setLittleEndian(false); // Intel param.setExtraFields(td.getFields());
static public final boolean saveAsTIFF(BufferedImage bi, final String path, final boolean as_grey) { if (!checkPath(path)) return false; synchronized (getPathLock(path)) { OutputStream out = null; try { if (as_grey) bi = asGrey(bi); final TIFFEncodeParam param = new TIFFEncodeParam(); // If the bi is larger than 512x512, I could use COMPRESSION_LZW or COMPRESSION_DEFLATE (zip-in-tiff, lossless), or COMPRESSION_JPEG_TTN2 (Jpeg-in-tiff) -- i.e. an adaptive strategy as suggested by Clay Reid param.setCompression(TIFFEncodeParam.COMPRESSION_NONE); out = new BufferedOutputStream(new FileOutputStream(path)); ImageCodec.createImageEncoder("TIFF", out, param).encode(bi); out.flush(); // !@#$% Couldn't it do it by itself? final File f = new File(path); return f.exists() && f.length() > 0; // no other way to check if the writing was successful } catch (FileNotFoundException fnfe) { Utils.log2("saveAsTIFF: Path not found: " + path); } catch (Exception e) { IJError.print(e, true); } finally { if (null != out) try { out.close(); } catch (Exception e) {} removePathLock(path); } } return false; }
params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4); params.setExtraImages(imageList.iterator()); TIFFField[] extras = new TIFFField[2];
params.setCompression(TIFFEncodeParam.COMPRESSION_GROUP3_1D); int changeName = 1; String tempCurrentFile = currentFile;
TIFFEncodeParam param = new TIFFEncodeParam(); param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4); param.setReverseFillOrder(true); param.setLittleEndian(true); param.setWriteTiled(false); param.setTileSize(-1, images[0].getHeight());
public byte[] convertToTiff() throws IOException { RenderedImage image = this.image; TIFFEncodeParam param = new TIFFEncodeParam(); param.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4); param.setLittleEndian(true); param.setTileSize(image.getWidth(), image.getHeight());