dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
204 stars 58 forks source link

How do you change the dpi of tif-file ? #30

Closed cod91 closed 8 years ago

cod91 commented 8 years ago

How do you change the dpi of tif-file?

dragon66 commented 8 years ago

@cod91 That's one of the things I left out when I wrote the TIFF writer and related stuff. I thought about put that into the code before but never really did it. I believe it could be done this way: add a new parameter to TIFFOptions for DPI and add a check in TIFFWriter for that parameter, then create and add a new TIFF field to the output image.

dragon66 commented 8 years ago

Added new parameters to TIFFOptions to set X resolution, Y resolution, as well as resolution unit.

You can use it like this:

TIFFOptions tiffOptions = new TIFFOptions();
tiffOptions.setXResolution(96);
tiffOptions.setYResolution(96);
tiffOptions.setResolutionUnit(ResolutionUnit.RESUNIT_INCH);

By default, it uses 72 for both X and Y resolution and inch as resolution unit. See testImageReader for more details on how to set ImageParam to image writers.

cod91 commented 8 years ago

Thank you for helping us take time