Skip to content

how to convert jpg to tiff #40

Answered by bosborn
mywsat asked this question in Q&A
Discussion options

You must be logged in to vote
String file = "/path/base_file_name";

BufferedImage img = ImageIO.read(new File(file + ".jpeg"));

int width = img.getWidth();
int height = img.getHeight();
int samplesPerPixel = 3;
FieldType fieldType = FieldType.BYTE;

Rasters rasters = new Rasters(width, height, samplesPerPixel,
		fieldType);

FileDirectory directory = new FileDirectory();
directory.setImageWidth(width);
directory.setImageHeight(height);
directory.setBitsPerSample(fieldType.getBits());
directory.setCompression(TiffConstants.COMPRESSION_NO);
directory.setPhotometricInterpretation(
		TiffConstants.PHOTOMETRIC_INTERPRETATION_RGB);
directory.setSamplesPerPixel(samplesPerPixel);
int planarConfiguration = TiffConstants.PLAN…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bosborn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants