Giter Club home page Giter Club logo

tiff-java's Introduction

TIFF Java

Tagged Image File Format Lib

The TIFF Library was developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with BIT Systems. The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the MIT license.

Pull Requests

If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.

Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license.

About

TIFF is a Java library for reading and writing Tagged Image File Format files. It was primarily created to provide license friendly TIFF functionality to Android applications. Implementation is based on the TIFF specification and this JavaScript implementation: https://github.com/constantinius/geotiff.js

Usage

View the latest Javadoc

Read

//File input = ...
//InputStream input = ...
//byte[] input = ...
//ByteReader input = ...

TIFFImage tiffImage = TiffReader.readTiff(input);
List<FileDirectory> directories = tiffImage.getFileDirectories();
FileDirectory directory = directories.get(0);
Rasters rasters = directory.readRasters();

Write

int width = 256;
int height = 256;
int samplesPerPixel = 1;
FieldType fieldType = FieldType.FLOAT;
int bitsPerSample = fieldType.getBits();

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

int rowsPerStrip = rasters.calculateRowsPerStrip(
		TiffConstants.PLANAR_CONFIGURATION_CHUNKY);

FileDirectory directory = new FileDirectory();
directory.setImageWidth(width);
directory.setImageHeight(height);
directory.setBitsPerSample(bitsPerSample);
directory.setCompression(TiffConstants.COMPRESSION_NO);
directory.setPhotometricInterpretation(
		TiffConstants.PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO);
directory.setSamplesPerPixel(samplesPerPixel);
directory.setRowsPerStrip(rowsPerStrip);
directory.setPlanarConfiguration(
		TiffConstants.PLANAR_CONFIGURATION_CHUNKY);
directory.setSampleFormat(TiffConstants.SAMPLE_FORMAT_FLOAT);
directory.setWriteRasters(rasters);

for (int y = 0; y < height; y++) {
	for (int x = 0; x < width; x++) {
		float pixelValue = 1.0f; // any pixel value
		rasters.setFirstPixelSample(x, y, pixelValue);
	}
}

TIFFImage tiffImage = new TIFFImage();
tiffImage.add(directory);
byte[] bytes = TiffWriter.writeTiffToBytes(tiffImage);
// or
// File file = ...
// TiffWriter.writeTiff(file, tiffImage);

Installation

Pull from the Maven Central Repository (JAR, POM, Source, Javadoc)

<dependency>
    <groupId>mil.nga</groupId>
    <artifactId>tiff</artifactId>
    <version>3.0.0</version>
</dependency>

Build

Build & Test

Build this repository using Eclipse and/or Maven:

mvn clean install

tiff-java's People

Contributors

bosborn avatar kipliklotrika avatar jochenwilhelmytomtom avatar btuttle avatar bradh avatar jeongyong-park avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.