tiff

package module
v0.0.0-...-4ec2aa2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: BSD-3-Clause Imports: 19 Imported by: 0

README


TIFF for Go

Build Status GoDoc

Features:

  1. Support BigTiff
  2. Support decode multiple image
  3. Support decode subifd image
  4. Support RGB format
  5. Support Float DataType
  6. More ...

Install

  1. go get github.com/chai2010/tiff
  2. go run hello.go

Example

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"path/filepath"

	tiff "github.com/chai2010/tiff"
)

func main() {
	var data []byte
	var err error

	var files = []string{
		"./testdata/BigTIFFSamples/BigTIFFSubIFD8.tif",
		"./testdata/multipage/multipage-gopher.tif",
	}
	for _, filename := range files {
		// Load file data
		if data, err = ioutil.ReadFile(filename); err != nil {
			log.Fatal(err)
		}

		// Decode tiff
		m, errors, err := tiff.DecodeAll(bytes.NewReader(data))
		if err != nil {
			log.Println(err)
		}

		// Encode tiff
		for i := 0; i < len(m); i++ {
			for j := 0; j < len(m[i]); j++ {
				newname := fmt.Sprintf("%s-%02d-%02d.tiff", filepath.Base(filename), i, j)
				if errors[i][j] != nil {
					log.Printf("%s: %v\n", newname, err)
					continue
				}

				var buf bytes.Buffer
				if err = tiff.Encode(&buf, m[i][j], nil); err != nil {
					log.Fatal(err)
				}
				if err = ioutil.WriteFile(newname, buf.Bytes(), 0666); err != nil {
					log.Fatal(err)
				}
				fmt.Printf("Save %s ok\n", newname)
			}
		}
	}
}

BUGS

Report bugs to chaishushan@gmail.com.

Thanks!

Documentation

Overview

Package tiff offers a rich TIFF/BigTIFF/GeoTIFF decoder/encoder for Go.

The Classic TIFF specification is at http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf

The Big TIFF specification is at http://www.remotesensing.org/libtiff/bigtiffdesign.html

The Geo TIFF specification is at http://www.remotesensing.org/geotiff/spec/geotiffhome.html

TIFF Tags: http://www.awaresystems.be/imaging/tiff/tifftags.html

Features:

  1. Support BigTiff
  2. Support decode multiple image
  3. Support decode subifd image
  4. Support RGB format
  5. Support Float DataType
  6. More ...

Example:

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"
	"path/filepath"

	tiff "github.com/chai2010/tiff"
)

func main() {
	var data []byte
	var err error

	var files = []string{
		"./testdata/BigTIFFSamples/BigTIFFSubIFD8.tif",
		"./testdata/multipage/multipage-gopher.tif",
	}
	for _, filename := range files {
		// Load file data
		if data, err = ioutil.ReadFile(filename); err != nil {
			log.Fatal(err)
		}

		// Decode tiff
		m, errors, err := tiff.DecodeAll(bytes.NewReader(data))
		if err != nil {
			log.Println(err)
		}

		// Encode tiff
		for i := 0; i < len(m); i++ {
			for j := 0; j < len(m[i]); j++ {
				newname := fmt.Sprintf("%s-%02d-%02d.tiff", filepath.Base(filename), i, j)
				if errors[i][j] != nil {
					log.Printf("%s: %v\n", newname, err)
					continue
				}

				var buf bytes.Buffer
				if err = tiff.Encode(&buf, m[i][j], nil); err != nil {
					log.Fatal(err)
				}
				if err = ioutil.WriteFile(newname, buf.Bytes(), 0666); err != nil {
					log.Fatal(err)
				}
				fmt.Printf("Save %s ok\n", newname)
			}
		}
	}
}

Report bugs to <chaishushan@gmail.com>.

Thanks!

Index

Constants

View Source
const (
	ClassicTiffLittleEnding = "II\x2A\x00"
	ClassicTiffBigEnding    = "MM\x00\x2A"
	BigTiffLittleEnding     = "II\x2B\x00"
	BigTiffBigEnding        = "MM\x00\x2B"
)
View Source
const (
	TagType_NewSubfileType TagType = 254 // LONG , 1, # Default=0. subfile data descriptor

	TagValue_NewSubfileType_Nil               TagValue_NewSubfileType = 0 //
	TagValue_NewSubfileType_Reduced           TagValue_NewSubfileType = 1 // # bit0, reduced resolution version
	TagValue_NewSubfileType_Page              TagValue_NewSubfileType = 2 // # bit1, one page of many
	TagValue_NewSubfileType_Reduced_Page      TagValue_NewSubfileType = 3 //
	TagValue_NewSubfileType_Mask              TagValue_NewSubfileType = 4 // # bit2, transparency mask
	TagValue_NewSubfileType_Reduced_Mask      TagValue_NewSubfileType = 5 //
	TagValue_NewSubfileType_Page_Mask         TagValue_NewSubfileType = 6 //
	TagValue_NewSubfileType_Reduced_Page_Mask TagValue_NewSubfileType = 7 //

	TagType_SubfileType TagType = 255 // SHORT, 1, # kind of data in subfile

	TagValue_SubfileType_Image        TagValue_SubfileType = 1 // # full resolution image data
	TagValue_SubfileType_ReducedImage TagValue_SubfileType = 2 // # reduced size image data
	TagValue_SubfileType_Page         TagValue_SubfileType = 3 // # one page of many

	TagType_ImageWidth    TagType = 256 // SHORT/LONG/LONG8, 1, # Required
	TagType_ImageLength   TagType = 257 // SHORT/LONG/LONG8, 1, # Required
	TagType_BitsPerSample TagType = 258 // SHORT, *, # Default=1. See SamplesPerPixel
	TagType_Compression   TagType = 259 // SHORT, 1, # Default=1

	TagValue_CompressionType_Nil        TagValue_CompressionType = 0     //
	TagValue_CompressionType_None       TagValue_CompressionType = 1     //
	TagValue_CompressionType_CCITT      TagValue_CompressionType = 2     //
	TagValue_CompressionType_G3         TagValue_CompressionType = 3     // # Group 3 Fax.
	TagValue_CompressionType_G4         TagValue_CompressionType = 4     // # Group 4 Fax.
	TagValue_CompressionType_LZW        TagValue_CompressionType = 5     //
	TagValue_CompressionType_JPEGOld    TagValue_CompressionType = 6     // # Superseded by cJPEG.
	TagValue_CompressionType_JPEG       TagValue_CompressionType = 7     //
	TagValue_CompressionType_Deflate    TagValue_CompressionType = 8     // # zlib compression.
	TagValue_CompressionType_PackBits   TagValue_CompressionType = 32773 //
	TagValue_CompressionType_DeflateOld TagValue_CompressionType = 32946 // # Superseded by cDeflate.

	TagType_PhotometricInterpretation TagType = 262 // SHORT, 1,

	TagValue_PhotometricType_WhiteIsZero TagValue_PhotometricType = 0 //
	TagValue_PhotometricType_BlackIsZero TagValue_PhotometricType = 1 //
	TagValue_PhotometricType_RGB         TagValue_PhotometricType = 2 //
	TagValue_PhotometricType_Paletted    TagValue_PhotometricType = 3 //
	TagValue_PhotometricType_TransMask   TagValue_PhotometricType = 4 // # transparency mask
	TagValue_PhotometricType_CMYK        TagValue_PhotometricType = 5 //
	TagValue_PhotometricType_YCbCr       TagValue_PhotometricType = 6 //
	TagValue_PhotometricType_CIELab      TagValue_PhotometricType = 8 //

	TagType_Threshholding       TagType = 263 // SHORT, 1, # Default=1
	TagType_CellWidth           TagType = 264 // SHORT, 1,
	TagType_CellLenght          TagType = 265 // SHORT, 1,
	TagType_FillOrder           TagType = 266 // SHORT, 1, # Default=1
	TagType_DocumentName        TagType = 269 // ASCII
	TagType_ImageDescription    TagType = 270 // ASCII
	TagType_Make                TagType = 271 // ASCII
	TagType_Model               TagType = 272 // ASCII
	TagType_StripOffsets        TagType = 273 // SHORT/LONG/LONG8, *, # StripsPerImage
	TagType_Orientation         TagType = 274 // SHORT, 1, # Default=1
	TagType_SamplesPerPixel     TagType = 277 // SHORT, 1, # Default=1
	TagType_RowsPerStrip        TagType = 278 // SHORT/LONG/LONG8, 1,
	TagType_StripByteCounts     TagType = 279 // SHORT/LONG/LONG8, *, # StripsPerImage
	TagType_MinSampleValue      TagType = 280 // SHORT,    *, # Default=0
	TagType_MaxSampleValue      TagType = 281 // SHORT,    *, # Default=2^BitsPerSample-1
	TagType_XResolution         TagType = 282 // RATIONAL, 1, # Required?
	TagType_YResolution         TagType = 283 // RATIONAL, 1, # Required?
	TagType_PlanarConfiguration TagType = 284 // SHORT,    1, # Defaule=1
	TagType_PageName            TagType = 285 // ASCII
	TagType_XPosition           TagType = 286 // RATIONAL,   1
	TagType_YPosition           TagType = 287 // RATIONAL,   1
	TagType_FreeOffsets         TagType = 288 // LONG/LONG8, *
	TagType_FreeByteCounts      TagType = 289 // LONG/LONG8, *
	TagType_GrayResponseUnit    TagType = 290 // SHORT, 1,
	TagType_GrayResponseCurve   TagType = 291 // SHORT, *, # 2**BitPerSample
	TagType_T4Options           TagType = 292 // LONG,  1, # Default=0
	TagType_T6Options           TagType = 293 // LONG,  1, # Default=0
	TagType_ResolutionUnit      TagType = 296 // SHORT, 1, # Default=2

	TagValue_ResolutionUnitType_None    TagValue_ResolutionUnitType = 1 //
	TagValue_ResolutionUnitType_PerInch TagValue_ResolutionUnitType = 2 // # Dots per inch.
	TagValue_ResolutionUnitType_PerCM   TagValue_ResolutionUnitType = 3 // # Dots per centimeter.

	TagType_PageNumber       TagType = 297 // SHORT, 2,
	TagType_TransferFunction TagType = 301 // SHORT, *, # {1 or SamplesPerPixel}*2**BitPerSample
	TagType_Software         TagType = 305 // ASCII
	TagType_DateTime         TagType = 306 // ASCII, 20, # YYYY:MM:DD HH:MM:SS, include NULL
	TagType_Artist           TagType = 315 // ASCII
	TagType_HostComputer     TagType = 316 // ASCII
	TagType_Predictor        TagType = 317 // SHORT, 1, # Default=1

	TagValue_PredictorType_None       TagValue_PredictorType = 1 //
	TagValue_PredictorType_Horizontal TagValue_PredictorType = 2 //

	TagType_WhitePoint             TagType = 318 // RATIONAL, 2
	TagType_PrimaryChromaticities  TagType = 319 // RATIONAL, 6
	TagType_ColorMap               TagType = 320 // SHORT, *, # 3*(2**BitPerSample)
	TagType_HalftoneHints          TagType = 321 // SHORT, 2
	TagType_TileWidth              TagType = 322 // SHORT/LONG, 1
	TagType_TileLength             TagType = 323 // SHORT/LONG, 1
	TagType_TileOffsets            TagType = 324 // LONG/LONG8, *, # TilesPerImage
	TagType_TileByteCounts         TagType = 325 // SHORT/LONG, *, # TilesPerImage
	TagType_BadFaxLines            TagType = 326 // ingore # Used in the TIFF-F standard, denotes the number of 'bad' scan lines encountered by the facsimile device.
	TagType_CleanFaxData           TagType = 327 // ingore # Used in the TIFF-F standard, indicates if 'bad' lines encountered during reception are stored in the data, or if 'bad' lines have been replaced by the receiver.
	TagType_ConsecutiveBadFaxLines TagType = 328 // ingore # Used in the TIFF-F standard, denotes the maximum number of consecutive 'bad' scanlines received.
	TagType_SubIFD                 TagType = 330 // IFD,   *  # IFD pointer
	TagType_InkSet                 TagType = 332 // SHORT, 1, # Default=1
	TagType_InkNames               TagType = 333 // ASCII
	TagType_NumberOfInks           TagType = 334 // SHORT, 1, # Default=4
	TagType_DotRange               TagType = 336 // BYTE/SHORT, # Default=[0,2^BitsPerSample-1]
	TagType_TargetPrinter          TagType = 337 // ASCII
	TagType_ExtraSamples           TagType = 338 // BYTE,  1,
	TagType_SampleFormat           TagType = 339 // SHORT, *, # SamplesPerPixel. Default=1

	TagValue_SampleFormatType_Uint      TagValue_SampleFormatType = 1 //
	TagValue_SampleFormatType_TwoInt    TagValue_SampleFormatType = 2 //
	TagValue_SampleFormatType_Float     TagValue_SampleFormatType = 3 //
	TagValue_SampleFormatType_Undefined TagValue_SampleFormatType = 4 //

	TagType_SMinSampleValue              TagType = 340   // *,     *, # SamplesPerPixel, try double
	TagType_SMaxSampleValue              TagType = 341   // *,     *, # SamplesPerPixel, try double
	TagType_TransferRange                TagType = 342   // SHORT, 6,
	TagType_ClipPath                     TagType = 343   // ingore # Mirrors the essentials of PostScript's path creation functionality.
	TagType_XClipPathUnits               TagType = 344   // ingore # The number of units that span the width of the image, in terms of integer ClipPath coordinates.
	TagType_YClipPathUnits               TagType = 345   // ingore # The number of units that span the height of the image, in terms of integer ClipPath coordinates.
	TagType_Indexed                      TagType = 346   // ingore # Aims to broaden the support for indexed images to include support for any color space.
	TagType_JPEGTables                   TagType = 347   // ingore # JPEG quantization and/or Huffman tables.
	TagType_OPIProxy                     TagType = 351   // ingore # OPI-related.
	TagType_GlobalParametersIFD          TagType = 400   // ingore # Used in the TIFF-FX standard to point to an IFD containing tags that are globally applicable to the complete TIFF file.
	TagType_ProfileType                  TagType = 401   // ingore # Used in the TIFF-FX standard, denotes the type of data stored in this file or IFD.
	TagType_FaxProfile                   TagType = 402   // ingore # Used in the TIFF-FX standard, denotes the 'profile' that applies to this file.
	TagType_CodingMethods                TagType = 403   // ingore # Used in the TIFF-FX standard, indicates which coding methods are used in the file.
	TagType_VersionYear                  TagType = 404   // ingore # Used in the TIFF-FX standard, denotes the year of the standard specified by the FaxProfile field.
	TagType_ModeNumber                   TagType = 405   // ingore # Used in the TIFF-FX standard, denotes the mode of the standard specified by the FaxProfile field.
	TagType_Decode                       TagType = 433   // ingore # Used in the TIFF-F and TIFF-FX standards, holds information about the ITULAB (PhotometricInterpretation = 10) encoding.
	TagType_DefaultImageColor            TagType = 434   // ingore # Defined in the Mixed Raster Content part of RFC 2301, is the default color needed in areas where no image is available.
	TagType_JPEGProc                     TagType = 512   // SHORT, 1,
	TagType_JPEGInterchangeFormat        TagType = 513   // LONG,  1,
	TagType_JPEGInterchangeFormatLength  TagType = 514   // LONG,  1,
	TagType_JPEGRestartInterval          TagType = 515   // SHORT, 1,
	TagType_JPEGLosslessPredictors       TagType = 517   // SHORT, *, # SamplesPerPixel
	TagType_JPEGPointTransforms          TagType = 518   // SHORT, *, # SamplesPerPixel
	TagType_JPEGQTables                  TagType = 519   // LONG,  *, # SamplesPerPixel
	TagType_JPEGDCTables                 TagType = 520   // LONG,  *, # SamplesPerPixel
	TagType_JPEGACTables                 TagType = 521   // LONG,  *, # SamplesPerPixel
	TagType_YCbCrCoefficients            TagType = 529   // RATIONAL, 3
	TagType_YCbCrSubSampling             TagType = 530   // SHORT, 2, # Default=[2,2]
	TagType_YCbCrPositioning             TagType = 531   // SHORT, 1, # Default=1
	TagType_ReferenceBlackWhite          TagType = 532   // LONG , *, # 2*SamplesPerPixel
	TagType_StripRowCounts               TagType = 559   // ingore # Defined in the Mixed Raster Content part of RFC 2301, used to replace RowsPerStrip for IFDs with variable-sized strips.
	TagType_XMP                          TagType = 700   // ingore # XML packet containing XMP metadata
	TagType_ImageID                      TagType = 32781 // ingore # OPI-related.
	TagType_ImageLayer                   TagType = 34732 // ingore # Defined in the Mixed Raster Content part of RFC 2301, used to denote the particular function of this Image in the mixed raster scheme.
	TagType_Copyright                    TagType = 33432 // ASCII
	TagType_WangAnnotation               TagType = 32932 // ingore # Annotation data, as used in 'Imaging for Windows'.
	TagType_MDFileTag                    TagType = 33445 // ingore # Specifies the pixel data format encoding in the Molecular Dynamics GEL file format.
	TagType_MDScalePixel                 TagType = 33446 // ingore # Specifies a scale factor in the Molecular Dynamics GEL file format.
	TagType_MDColorTable                 TagType = 33447 // ingore # Used to specify the conversion from 16bit to 8bit in the Molecular Dynamics GEL file format.
	TagType_MDLabName                    TagType = 33448 // ingore # Name of the lab that scanned this file, as used in the Molecular Dynamics GEL file format.
	TagType_MDSampleInfo                 TagType = 33449 // ingore # Information about the sample, as used in the Molecular Dynamics GEL file format.
	TagType_MDPrepDate                   TagType = 33450 // ingore # Date the sample was prepared, as used in the Molecular Dynamics GEL file format.
	TagType_MDPrepTime                   TagType = 33451 // ingore # Time the sample was prepared, as used in the Molecular Dynamics GEL file format.
	TagType_MDFileUnits                  TagType = 33452 // ingore # Units for data in this file, as used in the Molecular Dynamics GEL file format.
	TagType_ModelPixelScaleTag           TagType = 33550 // DOUBLE # Used in interchangeable GeoTIFF files.
	TagType_IPTC                         TagType = 33723 // ingore # IPTC (International Press Telecommunications Council) metadata.
	TagType_INGRPacketDataTag            TagType = 33918 // ingore # Intergraph Application specific storage.
	TagType_INGRFlagRegisters            TagType = 33919 // ingore # Intergraph Application specific flags.
	TagType_IrasBTransformationMatrix    TagType = 33920 // DOUBLE, 17 # Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only.
	TagType_ModelTiepointTag             TagType = 33922 // DOUBLE # Originally part of Intergraph's GeoTIFF tags, but now used in interchangeable GeoTIFF files.
	TagType_ModelTransformationTag       TagType = 34264 // DOUBLE, 16 # Used in interchangeable GeoTIFF files.
	TagType_Photoshop                    TagType = 34377 // ingore # Collection of Photoshop 'Image Resource Blocks'.
	TagType_ExifIFD                      TagType = 34665 // IFD    # A pointer to the Exif IFD.
	TagType_ICCProfile                   TagType = 34675 // ingore # ICC profile data.
	TagType_GeoKeyDirectoryTag           TagType = 34735 // SHORT, *, # >= 4
	TagType_GeoDoubleParamsTag           TagType = 34736 // DOUBLE
	TagType_GeoAsciiParamsTag            TagType = 34737 // ASCII
	TagType_GPSIFD                       TagType = 34853 // IFD    # A pointer to the Exif-related GPS Info IFD.
	TagType_HylaFAXFaxRecvParams         TagType = 34908 // ingore # Used by HylaFAX.
	TagType_HylaFAXFaxSubAddress         TagType = 34909 // ingore # Used by HylaFAX.
	TagType_HylaFAXFaxRecvTime           TagType = 34910 // ingore # Used by HylaFAX.
	TagType_ImageSourceData              TagType = 37724 // ingore # Used by Adobe Photoshop.
	TagType_InteroperabilityIFD          TagType = 40965 // IFD    # A pointer to the Exif-related Interoperability IFD.
	TagType_GDAL_METADATA                TagType = 42112 // ingore # Used by the GDAL library, holds an XML list of name=value 'metadata' values about the image as a whole, and about specific samples.
	TagType_GDAL_NODATA                  TagType = 42113 // ingore # Used by the GDAL library, contains an ASCII encoded nodata or background pixel value.
	TagType_OceScanjobDescription        TagType = 50215 // ingore # Used in the Oce scanning process.
	TagType_OceApplicationSelector       TagType = 50216 // ingore # Used in the Oce scanning process.
	TagType_OceIdentificationNumber      TagType = 50217 // ingore # Used in the Oce scanning process.
	TagType_OceImageLogicCharacteristics TagType = 50218 // ingore # Used in the Oce scanning process.
	TagType_DNGVersion                   TagType = 50706 // ingore # Used in IFD 0 of DNG files.
	TagType_DNGBackwardVersion           TagType = 50707 // ingore # Used in IFD 0 of DNG files.
	TagType_UniqueCameraModel            TagType = 50708 // ingore # Used in IFD 0 of DNG files.
	TagType_LocalizedCameraModel         TagType = 50709 // ingore # Used in IFD 0 of DNG files.
	TagType_CFAPlaneColor                TagType = 50710 // ingore # Used in Raw IFD of DNG files.
	TagType_CFALayout                    TagType = 50711 // ingore # Used in Raw IFD of DNG files.
	TagType_LinearizationTable           TagType = 50712 // ingore # Used in Raw IFD of DNG files.
	TagType_BlackLevelRepeatDim          TagType = 50713 // ingore # Used in Raw IFD of DNG files.
	TagType_BlackLevel                   TagType = 50714 // ingore # Used in Raw IFD of DNG files.
	TagType_BlackLevelDeltaH             TagType = 50715 // ingore # Used in Raw IFD of DNG files.
	TagType_BlackLevelDeltaV             TagType = 50716 // ingore # Used in Raw IFD of DNG files.
	TagType_WhiteLevel                   TagType = 50717 // ingore # Used in Raw IFD of DNG files.
	TagType_DefaultScale                 TagType = 50718 // ingore # Used in Raw IFD of DNG files.
	TagType_DefaultCropOrigin            TagType = 50719 // ingore # Used in Raw IFD of DNG files.
	TagType_DefaultCropSize              TagType = 50720 // ingore # Used in Raw IFD of DNG files.
	TagType_ColorMatrix1                 TagType = 50721 // ingore # Used in IFD 0 of DNG files.
	TagType_ColorMatrix2                 TagType = 50722 // ingore # Used in IFD 0 of DNG files.
	TagType_CameraCalibration1           TagType = 50723 // ingore # Used in IFD 0 of DNG files.
	TagType_CameraCalibration2           TagType = 50724 // ingore # Used in IFD 0 of DNG files.
	TagType_ReductionMatrix1             TagType = 50725 // ingore # Used in IFD 0 of DNG files.
	TagType_ReductionMatrix2             TagType = 50726 // ingore # Used in IFD 0 of DNG files.
	TagType_AnalogBalance                TagType = 50727 // ingore # Used in IFD 0 of DNG files.
	TagType_AsShotNeutral                TagType = 50728 // ingore # Used in IFD 0 of DNG files.
	TagType_AsShotWhiteXY                TagType = 50729 // ingore # Used in IFD 0 of DNG files.
	TagType_BaselineExposure             TagType = 50730 // ingore # Used in IFD 0 of DNG files.
	TagType_BaselineNoise                TagType = 50731 // ingore # Used in IFD 0 of DNG files.
	TagType_BaselineSharpness            TagType = 50732 // ingore # Used in IFD 0 of DNG files.
	TagType_BayerGreenSplit              TagType = 50733 // ingore # Used in Raw IFD of DNG files.
	TagType_LinearResponseLimit          TagType = 50734 // ingore # Used in IFD 0 of DNG files.
	TagType_CameraSerialNumber           TagType = 50735 // ingore # Used in IFD 0 of DNG files.
	TagType_LensInfo                     TagType = 50736 // ingore # Used in IFD 0 of DNG files.
	TagType_ChromaBlurRadius             TagType = 50737 // ingore # Used in Raw IFD of DNG files.
	TagType_AntiAliasStrength            TagType = 50738 // ingore # Used in Raw IFD of DNG files.
	TagType_DNGPrivateData               TagType = 50740 // ingore # Used in IFD 0 of DNG files.
	TagType_MakerNoteSafety              TagType = 50741 // ingore # Used in IFD 0 of DNG files.
	TagType_CalibrationIlluminant1       TagType = 50778 // ingore # Used in IFD 0 of DNG files.
	TagType_CalibrationIlluminant2       TagType = 50779 // ingore # Used in IFD 0 of DNG files.
	TagType_BestQualityScale             TagType = 50780 // ingore # Used in Raw IFD of DNG files.
	TagType_AliasLayerMetadata           TagType = 50784 // ingore # Alias Sketchbook Pro layer usage description.

)
View Source
const (
	MemPMagic = "MemP" // See https://github.com/chai2010/image
)

Variables

This section is empty.

Functions

func ChannelsOf

func ChannelsOf(m image.Image) int

func ColorModel

func ColorModel(channels int, dataType reflect.Kind) color.Model

func Decode

func Decode(r io.Reader) (m image.Image, err error)

Decode reads a TIFF image from r and returns it as an image.Image. The type of Image returned depends on the contents of the TIFF.

func DecodeAll

func DecodeAll(r io.Reader) (m [][]image.Image, errors [][]error, err error)

func DecodeConfig

func DecodeConfig(r io.Reader) (cfg image.Config, err error)

DecodeConfig returns the color model and dimensions of a TIFF image without decoding the entire image.

func DecodeConfigAll

func DecodeConfigAll(r io.Reader) (cfg [][]image.Config, errors [][]error, err error)

func DepthOf

func DepthOf(m image.Image) int

func Encode

func Encode(w io.Writer, m image.Image, opt *Options) error

Encode writes the image m to w. opt determines the options used for encoding, such as the compression type. If opt is nil, an uncompressed image is written.

func EncodeAll

func EncodeAll(w io.Writer, m [][]image.Image, opt [][]*Options) error

func Load

func Load(filename string) (m image.Image, err error)

func Save

func Save(filename string, m image.Image, opt *Options) error

func SizeofImage

func SizeofImage(m image.Image) int

func SizeofKind

func SizeofKind(dataType reflect.Kind) int

func SizeofPixel

func SizeofPixel(channels int, dataType reflect.Kind) int

Types

type ColorModelInterface

type ColorModelInterface interface {
	Channels() int
	DataType() reflect.Kind
}

type DataType

type DataType uint16
const (
	DataType_Nil       DataType = 0  // placeholder, invalid
	DataType_Byte      DataType = 1  // 8-bit unsigned integer
	DataType_ASCII     DataType = 2  // 8-bit bytes w/ last byte null
	DataType_Short     DataType = 3  // 16-bit unsigned integer
	DataType_Long      DataType = 4  // 32-bit unsigned integer
	DataType_Rational  DataType = 5  // 64-bit unsigned fraction
	DataType_SByte     DataType = 6  // !8-bit signed integer
	DataType_Undefined DataType = 7  // !8-bit untyped data
	DataType_SShort    DataType = 8  // !16-bit signed integer
	DataType_SLong     DataType = 9  // !32-bit signed integer
	DataType_SRational DataType = 10 // !64-bit signed fraction
	DataType_Float     DataType = 11 // !32-bit IEEE floating point
	DataType_Double    DataType = 12 // !64-bit IEEE floating point
	DataType_IFD       DataType = 13 // %32-bit unsigned integer (offset)
	DataType_Long8     DataType = 16 // BigTIFF 64-bit unsigned integer
	DataType_SLong8    DataType = 17 // BigTIFF 64-bit signed integer
	DataType_IFD8      DataType = 18 // BigTIFF 64-bit unsigned integer (offset)
)

func (DataType) ByteSize

func (d DataType) ByteSize() int

func (DataType) IsFloatType

func (d DataType) IsFloatType() bool

func (DataType) IsIntType

func (d DataType) IsIntType() bool

func (DataType) IsRationalType

func (d DataType) IsRationalType() bool

func (DataType) IsStringType

func (d DataType) IsStringType() bool

func (DataType) String

func (p DataType) String() string

func (DataType) Valid

func (d DataType) Valid() bool

type ExifIFD_TagType

type ExifIFD_TagType TagType

EXIF Tags

const (
	ExifIFD_TagType_ExposureTime             ExifIFD_TagType = 33434 // ingore # Exposure time, given in seconds.
	ExifIFD_TagType_FNumber                  ExifIFD_TagType = 33437 // ingore # The F number.
	ExifIFD_TagType_ExposureProgram          ExifIFD_TagType = 34850 // ingore # The class of the program used by the camera to set exposure when the picture is taken.
	ExifIFD_TagType_SpectralSensitivity      ExifIFD_TagType = 34852 // ingore # Indicates the spectral sensitivity of each channel of the camera used.
	ExifIFD_TagType_ISOSpeedRatings          ExifIFD_TagType = 34855 // ingore # Indicates the ISO Speed and ISO Latitude of the camera or input device as specified in ISO 12232.
	ExifIFD_TagType_OECF                     ExifIFD_TagType = 34856 // ingore # Indicates the Opto-Electric Conversion Function (OECF) specified in ISO 14524.
	ExifIFD_TagType_ExifVersion              ExifIFD_TagType = 36864 // ingore # The version of the supported Exif standard.
	ExifIFD_TagType_DateTimeOriginal         ExifIFD_TagType = 36867 // ingore # The date and time when the original image data was generated.
	ExifIFD_TagType_DateTimeDigitized        ExifIFD_TagType = 36868 // ingore # The date and time when the image was stored as digital data.
	ExifIFD_TagType_ComponentsConfiguration  ExifIFD_TagType = 37121 // ingore # Specific to compressed data; specifies the channels and complements PhotometricInterpretation
	ExifIFD_TagType_CompressedBitsPerPixel   ExifIFD_TagType = 37122 // ingore # Specific to compressed data; states the compressed bits per pixel.
	ExifIFD_TagType_ShutterSpeedValue        ExifIFD_TagType = 37377 // ingore # Shutter speed.
	ExifIFD_TagType_ApertureValue            ExifIFD_TagType = 37378 // ingore # The lens aperture.
	ExifIFD_TagType_BrightnessValue          ExifIFD_TagType = 37379 // ingore # The value of brightness.
	ExifIFD_TagType_ExposureBiasValue        ExifIFD_TagType = 37380 // ingore # The exposure bias.
	ExifIFD_TagType_MaxApertureValue         ExifIFD_TagType = 37381 // ingore # The smallest F number of the lens.
	ExifIFD_TagType_SubjectDistance          ExifIFD_TagType = 37382 // ingore # The distance to the subject, given in meters.
	ExifIFD_TagType_MeteringMode             ExifIFD_TagType = 37383 // ingore # The metering mode.
	ExifIFD_TagType_LightSource              ExifIFD_TagType = 37384 // ingore # The kind of light source.
	ExifIFD_TagType_Flash                    ExifIFD_TagType = 37385 // ingore # Indicates the status of flash when the image was shot.
	ExifIFD_TagType_FocalLength              ExifIFD_TagType = 37386 // ingore # The actual focal length of the lens, in mm.
	ExifIFD_TagType_SubjectArea              ExifIFD_TagType = 37396 // ingore # Indicates the location and area of the main subject in the overall scene.
	ExifIFD_TagType_MakerNote                ExifIFD_TagType = 37500 // ingore # Manufacturer specific information.
	ExifIFD_TagType_UserComment              ExifIFD_TagType = 37510 // ingore # Keywords or comments on the image; complements ImageDescription.
	ExifIFD_TagType_SubsecTime               ExifIFD_TagType = 37520 // ingore # A tag used to record fractions of seconds for the DateTime tag.
	ExifIFD_TagType_SubsecTimeOriginal       ExifIFD_TagType = 37521 // ingore # A tag used to record fractions of seconds for the DateTimeOriginal tag.
	ExifIFD_TagType_SubsecTimeDigitized      ExifIFD_TagType = 37522 // ingore # A tag used to record fractions of seconds for the DateTimeDigitized tag.
	ExifIFD_TagType_FlashpixVersion          ExifIFD_TagType = 40960 // ingore # The Flashpix format version supported by a FPXR file.
	ExifIFD_TagType_ColorSpace               ExifIFD_TagType = 40961 // ingore # The color space information tag is always recorded as the color space specifier.
	ExifIFD_TagType_PixelXDimension          ExifIFD_TagType = 40962 // ingore # Specific to compressed data; the valid width of the meaningful image.
	ExifIFD_TagType_PixelYDimension          ExifIFD_TagType = 40963 // ingore # Specific to compressed data; the valid height of the meaningful image.
	ExifIFD_TagType_RelatedSoundFile         ExifIFD_TagType = 40964 // ingore # Used to record the name of an audio file related to the image data.
	ExifIFD_TagType_FlashEnergy              ExifIFD_TagType = 41483 // ingore # Indicates the strobe energy at the time the image is captured, as measured in Beam Candle Power Seconds
	ExifIFD_TagType_SpatialFrequencyResponse ExifIFD_TagType = 41484 // ingore # Records the camera or input device spatial frequency table and SFR values in the direction of image width, image height, and diagonal direction, as specified in ISO 12233.
	ExifIFD_TagType_FocalPlaneXResolution    ExifIFD_TagType = 41486 // ingore # Indicates the number of pixels in the image width (X) direction per FocalPlaneResolutionUnit on the camera focal plane.
	ExifIFD_TagType_FocalPlaneYResolution    ExifIFD_TagType = 41487 // ingore # Indicates the number of pixels in the image height (Y) direction per FocalPlaneResolutionUnit on the camera focal plane.
	ExifIFD_TagType_FocalPlaneResolutionUnit ExifIFD_TagType = 41488 // ingore # Indicates the unit for measuring FocalPlaneXResolution and FocalPlaneYResolution.
	ExifIFD_TagType_SubjectLocation          ExifIFD_TagType = 41492 // ingore # Indicates the location of the main subject in the scene.
	ExifIFD_TagType_ExposureIndex            ExifIFD_TagType = 41493 // ingore # Indicates the exposure index selected on the camera or input device at the time the image is captured.
	ExifIFD_TagType_SensingMethod            ExifIFD_TagType = 41495 // ingore # Indicates the image sensor type on the camera or input device.
	ExifIFD_TagType_FileSource               ExifIFD_TagType = 41728 // ingore # Indicates the image source.
	ExifIFD_TagType_SceneType                ExifIFD_TagType = 41729 // ingore # Indicates the type of scene.
	ExifIFD_TagType_CFAPattern               ExifIFD_TagType = 41730 // ingore # Indicates the color filter array (CFA) geometric pattern of the image sensor when a one-chip color area sensor is used.
	ExifIFD_TagType_CustomRendered           ExifIFD_TagType = 41985 // ingore # Indicates the use of special processing on image data, such as rendering geared to output.
	ExifIFD_TagType_ExposureMode             ExifIFD_TagType = 41986 // ingore # Indicates the exposure mode set when the image was shot.
	ExifIFD_TagType_WhiteBalance             ExifIFD_TagType = 41987 // ingore # Indicates the white balance mode set when the image was shot.
	ExifIFD_TagType_DigitalZoomRatio         ExifIFD_TagType = 41988 // ingore # Indicates the digital zoom ratio when the image was shot.
	ExifIFD_TagType_FocalLengthIn35mmFilm    ExifIFD_TagType = 41989 // ingore # Indicates the equivalent focal length assuming a 35mm film camera, in mm.
	ExifIFD_TagType_SceneCaptureType         ExifIFD_TagType = 41990 // ingore # Indicates the type of scene that was shot.
	ExifIFD_TagType_GainControl              ExifIFD_TagType = 41991 // ingore # Indicates the degree of overall image gain adjustment.
	ExifIFD_TagType_Contrast                 ExifIFD_TagType = 41992 // ingore # Indicates the direction of contrast processing applied by the camera when the image was shot.
	ExifIFD_TagType_Saturation               ExifIFD_TagType = 41993 // ingore # Indicates the direction of saturation processing applied by the camera when the image was shot.
	ExifIFD_TagType_Sharpness                ExifIFD_TagType = 41994 // ingore # Indicates the direction of sharpness processing applied by the camera when the image was shot.
	ExifIFD_TagType_DeviceSettingDescription ExifIFD_TagType = 41995 // ingore # This tag indicates information on the picture-taking conditions of a particular camera model.
	ExifIFD_TagType_SubjectDistanceRange     ExifIFD_TagType = 41996 // ingore # Indicates the distance to the subject.
	ExifIFD_TagType_ImageUniqueID            ExifIFD_TagType = 42016 // ingore # Indicates an identifier assigned uniquely to each image.
)

func (ExifIFD_TagType) String

func (p ExifIFD_TagType) String() string

type GPSIFD_TagType

type GPSIFD_TagType TagType

GPS Tags

const (
	GPSIFD_TagType_GPSVersionID        GPSIFD_TagType = 0  // ingore # Indicates the version of GPSInfoIFD.
	GPSIFD_TagType_GPSLatitudeRef      GPSIFD_TagType = 1  // ingore # Indicates whether the latitude is north or south latitude.
	GPSIFD_TagType_GPSLatitude         GPSIFD_TagType = 2  // ingore # Indicates the latitude.
	GPSIFD_TagType_GPSLongitudeRef     GPSIFD_TagType = 3  // ingore # Indicates whether the longitude is east or west longitude.
	GPSIFD_TagType_GPSLongitude        GPSIFD_TagType = 4  // ingore # Indicates the longitude.
	GPSIFD_TagType_GPSAltitudeRef      GPSIFD_TagType = 5  // ingore # Indicates the altitude used as the reference altitude.
	GPSIFD_TagType_GPSAltitude         GPSIFD_TagType = 6  // ingore # Indicates the altitude based on the reference in GPSAltitudeRef.
	GPSIFD_TagType_GPSTimeStamp        GPSIFD_TagType = 7  // ingore # Indicates the time as UTC (Coordinated Universal Time).
	GPSIFD_TagType_GPSSatellites       GPSIFD_TagType = 8  // ingore # Indicates the GPS satellites used for measurements.
	GPSIFD_TagType_GPSStatus           GPSIFD_TagType = 9  // ingore # Indicates the status of the GPS receiver when the image is recorded.
	GPSIFD_TagType_GPSMeasureMode      GPSIFD_TagType = 10 // ingore # Indicates the GPS measurement mode.
	GPSIFD_TagType_GPSDOP              GPSIFD_TagType = 11 // ingore # Indicates the GPS DOP (data degree of precision).
	GPSIFD_TagType_GPSSpeedRef         GPSIFD_TagType = 12 // ingore # Indicates the unit used to express the GPS receiver speed of movement.
	GPSIFD_TagType_GPSSpeed            GPSIFD_TagType = 13 // ingore # Indicates the speed of GPS receiver movement.
	GPSIFD_TagType_GPSTrackRef         GPSIFD_TagType = 14 // ingore # Indicates the reference for giving the direction of GPS receiver movement.
	GPSIFD_TagType_GPSTrack            GPSIFD_TagType = 15 // ingore # Indicates the direction of GPS receiver movement.
	GPSIFD_TagType_GPSImgDirectionRef  GPSIFD_TagType = 16 // ingore # Indicates the reference for giving the direction of the image when it is captured.
	GPSIFD_TagType_GPSImgDirection     GPSIFD_TagType = 17 // ingore # Indicates the direction of the image when it was captured.
	GPSIFD_TagType_GPSMapDatum         GPSIFD_TagType = 18 // ingore # Indicates the geodetic survey data used by the GPS receiver.
	GPSIFD_TagType_GPSDestLatitudeRef  GPSIFD_TagType = 19 // ingore # Indicates whether the latitude of the destination point is north or south latitude.
	GPSIFD_TagType_GPSDestLatitude     GPSIFD_TagType = 20 // ingore # Indicates the latitude of the destination point.
	GPSIFD_TagType_GPSDestLongitudeRef GPSIFD_TagType = 21 // ingore # Indicates whether the longitude of the destination point is east or west longitude.
	GPSIFD_TagType_GPSDestLongitude    GPSIFD_TagType = 22 // ingore # Indicates the longitude of the destination point.
	GPSIFD_TagType_GPSDestBearingRef   GPSIFD_TagType = 23 // ingore # Indicates the reference used for giving the bearing to the destination point.
	GPSIFD_TagType_GPSDestBearing      GPSIFD_TagType = 24 // ingore # Indicates the bearing to the destination point.
	GPSIFD_TagType_GPSDestDistanceRef  GPSIFD_TagType = 25 // ingore # Indicates the unit used to express the distance to the destination point.
	GPSIFD_TagType_GPSDestDistance     GPSIFD_TagType = 26 // ingore # Indicates the distance to the destination point.
	GPSIFD_TagType_GPSProcessingMethod GPSIFD_TagType = 27 // ingore # A character string recording the name of the method used for location finding.
	GPSIFD_TagType_GPSAreaInformation  GPSIFD_TagType = 28 // ingore # A character string recording the name of the GPS area.
	GPSIFD_TagType_GPSDateStamp        GPSIFD_TagType = 29 // ingore # A character string recording date and time information relative to UTC (Coordinated Universal Time).
	GPSIFD_TagType_GPSDifferential     GPSIFD_TagType = 30 // ingore # Indicates whether differential correction is applied to the GPS receiver.
)

func (GPSIFD_TagType) String

func (p GPSIFD_TagType) String() string
type Header struct {
	ByteOrder binary.ByteOrder
	TiffType  TiffType
	FirstIFD  int64
}

func NewHeader

func NewHeader(isBigTiff bool, firstIFD int64) *Header

func ReadHeader

func ReadHeader(r io.Reader) (header *Header, err error)

func (*Header) Bytes

func (p *Header) Bytes() []byte

func (*Header) HeadSize

func (p *Header) HeadSize() int

func (*Header) IsBigTiff

func (p *Header) IsBigTiff() bool

func (*Header) String

func (p *Header) String() string

func (*Header) Valid

func (p *Header) Valid() bool

type IFD

type IFD struct {
	Header   *Header
	EntryMap map[TagType]*IFDEntry
	ThisIFD  int64
	NextIFD  int64
}

func NewIFD

func NewIFD(hdr *Header, width, height, depth, channels int, kind reflect.Kind) (ifd *IFD)

func ReadIFD

func ReadIFD(r io.Reader, h *Header, offset int64) (ifd *IFD, err error)

func (*IFD) BlockBounds

func (p *IFD) BlockBounds(col, row int) image.Rectangle

func (*IFD) BlockCount

func (p *IFD) BlockCount(col, row int) int64

func (*IFD) BlockOffset

func (p *IFD) BlockOffset(col, row int) int64

func (*IFD) BlocksAcross

func (p *IFD) BlocksAcross() int

func (*IFD) BlocksDown

func (p *IFD) BlocksDown() int

func (*IFD) Bounds

func (p *IFD) Bounds() image.Rectangle

func (*IFD) Bytes

func (p *IFD) Bytes() []byte

func (*IFD) Channels

func (p *IFD) Channels() int

func (*IFD) ColorMap

func (p *IFD) ColorMap() (palette color.Palette)

func (*IFD) Compression

func (p *IFD) Compression() TagValue_CompressionType

func (*IFD) DecodeBlock

func (p *IFD) DecodeBlock(r io.ReadSeeker, col, row int, dst image.Image) (err error)

func (*IFD) Depth

func (p *IFD) Depth() int

func (*IFD) EncodeBlock

func (p *IFD) EncodeBlock(w io.Writer, col, row int, dst *MemPImage) (err error)

func (*IFD) ImageConfig

func (p *IFD) ImageConfig() (config image.Config, err error)

func (*IFD) ImageType

func (p *IFD) ImageType() ImageType

func (*IFD) String

func (p *IFD) String() string

func (*IFD) TagGetter

func (p *IFD) TagGetter() TagGetter

func (*IFD) TagSetter

func (p *IFD) TagSetter() TagSetter

func (*IFD) Valid

func (p *IFD) Valid() bool

type IFDEntry

type IFDEntry struct {
	Header   *Header
	Tag      TagType
	DataType DataType
	Count    int
	Offset   int64
	Data     []byte
}

func NewIFDEntry

func NewIFDEntry(hdr *Header, tag TagType, dataType DataType, data interface{}) (p *IFDEntry)

func (*IFDEntry) Bytes

func (p *IFDEntry) Bytes() (entry, data []byte)

func (*IFDEntry) GetFloats

func (p *IFDEntry) GetFloats() []float64

func (*IFDEntry) GetInts

func (p *IFDEntry) GetInts() []int64

func (*IFDEntry) GetRationals

func (p *IFDEntry) GetRationals() [][2]int64

func (*IFDEntry) GetString

func (p *IFDEntry) GetString() string

func (*IFDEntry) GetUndefined

func (p *IFDEntry) GetUndefined(value interface{}) interface{}

func (*IFDEntry) GetValue

func (p *IFDEntry) GetValue() interface{}

func (*IFDEntry) SetFloats

func (p *IFDEntry) SetFloats(value ...float64) (err error)

func (*IFDEntry) SetInts

func (p *IFDEntry) SetInts(value ...int64) (err error)

func (*IFDEntry) SetRationals

func (p *IFDEntry) SetRationals(value ...[2]int64) (err error)

func (*IFDEntry) SetString

func (p *IFDEntry) SetString(value string) (err error)

func (*IFDEntry) SetUndefined

func (p *IFDEntry) SetUndefined(value interface{}) (err error)

func (*IFDEntry) SetValue

func (p *IFDEntry) SetValue(value interface{}) (err error)

func (*IFDEntry) String

func (p *IFDEntry) String() string

func (*IFDEntry) Valid

func (p *IFDEntry) Valid() bool

type ImageType

type ImageType uint16
const (
	ImageType_Nil ImageType = iota
	ImageType_Bilevel
	ImageType_BilevelInvert
	ImageType_Paletted
	ImageType_Gray
	ImageType_GrayInvert
	ImageType_RGB
	ImageType_RGBA
	ImageType_NRGBA
)

func (ImageType) String

func (p ImageType) String() string

type InteroperabilityIFD_TagType

type InteroperabilityIFD_TagType TagType

Interoperability Tags

const (
	InteroperabilityIFD_TagType_InteroperabilityIndex InteroperabilityIFD_TagType = 1 // ingore # Indicates the identification of the Interoperability rule.
)

func (InteroperabilityIFD_TagType) String

type MemP

type MemP interface {
	MemPMagic() string
	Bounds() image.Rectangle
	Channels() int
	DataType() reflect.Kind
	Pix() []byte // PixSlice type

	// Stride is the Pix stride (in bytes, must align with SizeofKind(p.DataType))
	// between vertically adjacent pixels.
	Stride() int
}

MemP Image Spec (Native Endian), see https://github.com/chai2010/image.

type MemPColor

type MemPColor struct {
	Channels int
	DataType reflect.Kind
	Pix      PixSlice
}

func (MemPColor) RGBA

func (c MemPColor) RGBA() (r, g, b, a uint32)

type MemPImage

type MemPImage struct {
	XMemPMagic string // MemP
	XRect      image.Rectangle
	XChannels  int
	XDataType  reflect.Kind
	XPix       PixSlice
	XStride    int
}

func AsMemPImage

func AsMemPImage(m interface{}) (p *MemPImage, ok bool)

m is MemP or image.Image

func NewMemPImage

func NewMemPImage(r image.Rectangle, channels int, dataType reflect.Kind) *MemPImage

func NewMemPImageFrom

func NewMemPImageFrom(m image.Image) *MemPImage

func (*MemPImage) AsStdImage

func (p *MemPImage) AsStdImage() (m image.Image, ok bool)

func (*MemPImage) At

func (p *MemPImage) At(x, y int) color.Color

func (*MemPImage) Bounds

func (p *MemPImage) Bounds() image.Rectangle

func (*MemPImage) Channels

func (p *MemPImage) Channels() int

func (*MemPImage) Clone

func (p *MemPImage) Clone() *MemPImage

func (*MemPImage) ColorModel

func (p *MemPImage) ColorModel() color.Model

func (*MemPImage) DataType

func (p *MemPImage) DataType() reflect.Kind

func (*MemPImage) MemPMagic

func (p *MemPImage) MemPMagic() string

func (*MemPImage) Pix

func (p *MemPImage) Pix() []byte

func (*MemPImage) PixOffset

func (p *MemPImage) PixOffset(x, y int) int

func (*MemPImage) PixelAt

func (p *MemPImage) PixelAt(x, y int) []byte

func (*MemPImage) Set

func (p *MemPImage) Set(x, y int, c color.Color)

func (*MemPImage) SetPixel

func (p *MemPImage) SetPixel(x, y int, c []byte)

func (*MemPImage) StdImage

func (p *MemPImage) StdImage() image.Image

func (*MemPImage) Stride

func (p *MemPImage) Stride() int

func (*MemPImage) SubImage

func (p *MemPImage) SubImage(r image.Rectangle) image.Image

type Options

type Options struct {
	EntryMap map[TagType]*IFDEntry
}

func (*Options) TagGetter

func (p *Options) TagGetter() TagGetter

func (*Options) TagSetter

func (p *Options) TagSetter() TagSetter

type PixSlice

type PixSlice []byte

func AsPixSlice

func AsPixSlice(slice interface{}) (d PixSlice)

AsPixSlice convert a normal slice to byte slice.

Convert []X to []byte:

x := make([]X, xLen)
y := AsPixSlice(x)

func (PixSlice) Bytes

func (d PixSlice) Bytes() (v []byte)

func (PixSlice) Complex128s

func (d PixSlice) Complex128s() (v []complex128)

func (PixSlice) Complex64s

func (d PixSlice) Complex64s() (v []complex64)

func (PixSlice) Float32s

func (d PixSlice) Float32s() (v []float32)

func (PixSlice) Float64s

func (d PixSlice) Float64s() (v []float64)

func (PixSlice) Int16s

func (d PixSlice) Int16s() (v []int16)

func (PixSlice) Int32s

func (d PixSlice) Int32s() (v []int32)

func (PixSlice) Int64s

func (d PixSlice) Int64s() (v []int64)

func (PixSlice) Int8s

func (d PixSlice) Int8s() (v []int8)

func (PixSlice) SetValue

func (d PixSlice) SetValue(i int, dataType reflect.Kind, v float64)

func (PixSlice) Slice

func (d PixSlice) Slice(newSliceType reflect.Type) interface{}

Slice convert a normal slice to new type slice.

Convert []byte to []Y:

x := make([]byte, xLen)
y := PixSlice(x).Slice(reflect.TypeOf([]Y(nil))).([]Y)

func (PixSlice) SwapEndian

func (d PixSlice) SwapEndian(dataType reflect.Kind)

func (PixSlice) Uint16s

func (d PixSlice) Uint16s() (v []uint16)

func (PixSlice) Uint32s

func (d PixSlice) Uint32s() (v []uint32)

func (PixSlice) Uint64s

func (d PixSlice) Uint64s() (v []uint64)

func (PixSlice) Uint8s

func (d PixSlice) Uint8s() []uint8

func (PixSlice) Value

func (d PixSlice) Value(i int, dataType reflect.Kind) float64

type Reader

type Reader struct {
	Reader io.ReadSeeker
	Header *Header
	Ifd    [][]*IFD
	// contains filtered or unexported fields
}

func OpenReader

func OpenReader(r io.Reader) (p *Reader, err error)

func (*Reader) Close

func (p *Reader) Close() (err error)

func (*Reader) DecodeImage

func (p *Reader) DecodeImage(i, j int) (m image.Image, err error)

func (*Reader) DecodeImageBlock

func (p *Reader) DecodeImageBlock(i, j, col, row int) (m image.Image, err error)

func (*Reader) ImageBlockBounds

func (p *Reader) ImageBlockBounds(i, j, col, row int) image.Rectangle

func (*Reader) ImageBlocksAcross

func (p *Reader) ImageBlocksAcross(i, j int) int

func (*Reader) ImageBlocksDown

func (p *Reader) ImageBlocksDown(i, j int) int

func (*Reader) ImageConfig

func (p *Reader) ImageConfig(i, j int) (image.Config, error)

func (*Reader) ImageNum

func (p *Reader) ImageNum() int

func (*Reader) SubImageNum

func (p *Reader) SubImageNum(i int) int

type SizeofImager

type SizeofImager interface {
	SizeofImage() int
}

type TagGetter

type TagGetter interface {
	GetNewSubfileType() (value int64, ok bool)
	GetSubfileType() (value int64, ok bool)
	GetImageWidth() (value int64, ok bool)
	GetImageLength() (value int64, ok bool)
	GetBitsPerSample() (value []int64, ok bool)
	GetCompression() (value TagValue_CompressionType, ok bool)
	GetPhotometricInterpretation() (value TagValue_PhotometricType, ok bool)
	GetThreshholding() (value int64, ok bool)
	GetCellWidth() (value int64, ok bool)
	GetCellLenght() (value int64, ok bool)
	GetFillOrder() (value int64, ok bool)
	GetDocumentName() (value string, ok bool)
	GetImageDescription() (value string, ok bool)
	GetMake() (value string, ok bool)
	GetModel() (value string, ok bool)
	GetStripOffsets() (value []int64, ok bool)
	GetOrientation() (value int64, ok bool)
	GetSamplesPerPixel() (value int64, ok bool)
	GetRowsPerStrip() (value int64, ok bool)
	GetStripByteCounts() (value []int64, ok bool)
	GetMinSampleValue() (value []int64, ok bool)
	GetMaxSampleValue() (value []int64, ok bool)
	GetXResolution() (value [2]int64, ok bool)
	GetYResolution() (value [2]int64, ok bool)
	GetPlanarConfiguration() (value int64, ok bool)
	GetPageName() (value string, ok bool)
	GetXPosition() (value [2]int64, ok bool)
	GetYPosition() (value [2]int64, ok bool)
	GetFreeOffsets() (value []int64, ok bool)
	GetFreeByteCounts() (value []int64, ok bool)
	GetGrayResponseUnit() (value int64, ok bool)
	GetGrayResponseCurve() (value []int64, ok bool)
	GetT4Options() (value int64, ok bool)
	GetT6Options() (value int64, ok bool)
	GetResolutionUnit() (value TagValue_ResolutionUnitType, ok bool)
	GetPageNumber() (value []int64, ok bool)
	GetTransferFunction() (value []int64, ok bool)
	GetSoftware() (value string, ok bool)
	GetDateTime() (value time.Time, ok bool)
	GetArtist() (value string, ok bool)
	GetHostComputer() (value string, ok bool)
	GetPredictor() (value TagValue_PredictorType, ok bool)
	GetWhitePoint() (value [][2]int64, ok bool)
	GetPrimaryChromaticities() (value [][2]int64, ok bool)
	GetColorMap() (value [][3]uint16, ok bool)
	GetHalftoneHints() (value []int64, ok bool)
	GetTileWidth() (value int64, ok bool)
	GetTileLength() (value int64, ok bool)
	GetTileOffsets() (value []int64, ok bool)
	GetTileByteCounts() (value []int64, ok bool)
	GetSubIFD() (value []int64, ok bool)
	GetInkSet() (value int64, ok bool)
	GetInkNames() (value string, ok bool)
	GetNumberOfInks() (value int64, ok bool)
	GetDotRange() (value []int64, ok bool)
	GetTargetPrinter() (value string, ok bool)
	GetExtraSamples() (value int64, ok bool)
	GetSampleFormat() (value []int64, ok bool)
	GetSMinSampleValue() (value []float64, ok bool)
	GetSMaxSampleValue() (value []float64, ok bool)
	GetTransferRange() (value []int64, ok bool)
	GetJPEGProc() (value int64, ok bool)
	GetJPEGInterchangeFormat() (value int64, ok bool)
	GetJPEGInterchangeFormatLength() (value int64, ok bool)
	GetJPEGRestartInterval() (value int64, ok bool)
	GetJPEGLosslessPredictors() (value []int64, ok bool)
	GetJPEGPointTransforms() (value []int64, ok bool)
	GetJPEGQTables() (value []int64, ok bool)
	GetJPEGDCTables() (value []int64, ok bool)
	GetJPEGACTables() (value []int64, ok bool)
	GetYCbCrCoefficients() (value [][2]int64, ok bool)
	GetYCbCrSubSampling() (value []int64, ok bool)
	GetYCbCrPositioning() (value int64, ok bool)
	GetReferenceBlackWhite() (value []int64, ok bool)
	GetCopyright() (value string, ok bool)
	GetModelPixelScaleTag() (value []float64, ok bool)
	GetIrasBTransformationMatrix() (value []float64, ok bool)
	GetModelTiepointTag() (value []float64, ok bool)
	GetModelTransformationTag() (value []float64, ok bool)
	GetExifIFD() (value []int64, ok bool)
	GetGeoKeyDirectoryTag() (value []int64, ok bool)
	GetGeoDoubleParamsTag() (value []float64, ok bool)
	GetGeoAsciiParamsTag() (value string, ok bool)
	GetGPSIFD() (value []int64, ok bool)
	GetInteroperabilityIFD() (value []int64, ok bool)

	GetUnknown(tag TagType) (value []byte, ok bool)
	// contains filtered or unexported methods
}

type TagSetter

type TagSetter interface {
	SetNewSubfileType(value int64) (ok bool)
	SetSubfileType(value int64) (ok bool)
	SetImageWidth(value int64) (ok bool)
	SetImageLength(value int64) (ok bool)
	SetBitsPerSample(value []int64) (ok bool)
	SetCompression(value TagValue_CompressionType) (ok bool)
	SetPhotometricInterpretation(value TagValue_PhotometricType) (ok bool)
	SetThreshholding(value int64) (ok bool)
	SetCellWidth(value int64) (ok bool)
	SetCellLenght(value int64) (ok bool)
	SetFillOrder(value int64) (ok bool)
	SetDocumentName(value string) (ok bool)
	SetImageDescription(value string) (ok bool)
	SetMake(value string) (ok bool)
	SetModel(value string) (ok bool)
	SetStripOffsets(value []int64) (ok bool)
	SetOrientation(value int64) (ok bool)
	SetSamplesPerPixel(value int64) (ok bool)
	SetRowsPerStrip(value int64) (ok bool)
	SetStripByteCounts(value []int64) (ok bool)
	SetMinSampleValue(value []int64) (ok bool)
	SetMaxSampleValue(value []int64) (ok bool)
	SetXResolution(value [2]int64) (ok bool)
	SetYResolution(value [2]int64) (ok bool)
	SetPlanarConfiguration(value int64) (ok bool)
	SetPageName(value string) (ok bool)
	SetXPosition(value [2]int64) (ok bool)
	SetYPosition(value [2]int64) (ok bool)
	SetFreeOffsets(value []int64) (ok bool)
	SetFreeByteCounts(value []int64) (ok bool)
	SetGrayResponseUnit(value int64) (ok bool)
	SetGrayResponseCurve(value []int64) (ok bool)
	SetT4Options(value int64) (ok bool)
	SetT6Options(value int64) (ok bool)
	SetResolutionUnit(value TagValue_ResolutionUnitType) (ok bool)
	SetPageNumber(value []int64) (ok bool)
	SetTransferFunction(value []int64) (ok bool)
	SetSoftware(value string) (ok bool)
	SetDateTime(value time.Time) (ok bool)
	SetArtist(value string) (ok bool)
	SetHostComputer(value string) (ok bool)
	SetPredictor(value TagValue_PredictorType) (ok bool)
	SetWhitePoint(value [][2]int64) (ok bool)
	SetPrimaryChromaticities(value [][2]int64) (ok bool)
	SetColorMap(value [][3]uint16) (ok bool)
	SetHalftoneHints(value []int64) (ok bool)
	SetTileWidth(value int64) (ok bool)
	SetTileLength(value int64) (ok bool)
	SetTileOffsets(value []int64) (ok bool)
	SetTileByteCounts(value []int64) (ok bool)
	SetSubIFD(value []int64) (ok bool)
	SetInkSet(value int64) (ok bool)
	SetInkNames(value string) (ok bool)
	SetNumberOfInks(value int64) (ok bool)
	SetDotRange(value []int64) (ok bool)
	SetTargetPrinter(value string) (ok bool)
	SetExtraSamples(value int64) (ok bool)
	SetSampleFormat(value []int64) (ok bool)
	SetSMinSampleValue(value []float64) (ok bool)
	SetSMaxSampleValue(value []float64) (ok bool)
	SetTransferRange(value []int64) (ok bool)
	SetJPEGProc(value int64) (ok bool)
	SetJPEGInterchangeFormat(value int64) (ok bool)
	SetJPEGInterchangeFormatLength(value int64) (ok bool)
	SetJPEGRestartInterval(value int64) (ok bool)
	SetJPEGLosslessPredictors(value []int64) (ok bool)
	SetJPEGPointTransforms(value []int64) (ok bool)
	SetJPEGQTables(value []int64) (ok bool)
	SetJPEGDCTables(value []int64) (ok bool)
	SetJPEGACTables(value []int64) (ok bool)
	SetYCbCrCoefficients(value [][2]int64) (ok bool)
	SetYCbCrSubSampling(value []int64) (ok bool)
	SetYCbCrPositioning(value int64) (ok bool)
	SetReferenceBlackWhite(value []int64) (ok bool)
	SetCopyright(value string) (ok bool)
	SetModelPixelScaleTag(value []float64) (ok bool)
	SetIrasBTransformationMatrix(value []float64) (ok bool)
	SetModelTiepointTag(value []float64) (ok bool)
	SetModelTransformationTag(value []float64) (ok bool)
	SetExifIFD(value []int64) (ok bool)
	SetGeoKeyDirectoryTag(value []int64) (ok bool)
	SetGeoDoubleParamsTag(value []float64) (ok bool)
	SetGeoAsciiParamsTag(value string) (ok bool)
	SetGPSIFD(value []int64) (ok bool)
	SetInteroperabilityIFD(value []int64) (ok bool)

	SetUnknown(tag TagType, value interface{}) (ok bool)
	// contains filtered or unexported methods
}

type TagType

type TagType uint16

func (TagType) String

func (p TagType) String() string

func (TagType) Valid

func (d TagType) Valid() bool

type TagValue_CompressionType

type TagValue_CompressionType TagType

func (TagValue_CompressionType) Decode

func (p TagValue_CompressionType) Decode(r io.Reader, width, height int) (data []byte, err error)

func (TagValue_CompressionType) String

func (p TagValue_CompressionType) String() string

type TagValue_NewSubfileType

type TagValue_NewSubfileType TagType

func (TagValue_NewSubfileType) String

func (p TagValue_NewSubfileType) String() string

type TagValue_PhotometricType

type TagValue_PhotometricType TagType

func (TagValue_PhotometricType) String

func (p TagValue_PhotometricType) String() string

type TagValue_PredictorType

type TagValue_PredictorType TagType

func (TagValue_PredictorType) String

func (p TagValue_PredictorType) String() string

type TagValue_ResolutionUnitType

type TagValue_ResolutionUnitType TagType

func (TagValue_ResolutionUnitType) String

type TagValue_SampleFormatType

type TagValue_SampleFormatType TagType

func (TagValue_SampleFormatType) String

func (p TagValue_SampleFormatType) String() string

type TagValue_SubfileType

type TagValue_SubfileType TagType

func (TagValue_SubfileType) String

func (p TagValue_SubfileType) String() string

type TiffType

type TiffType uint16
const (
	TiffType_ClassicTIFF TiffType = 42
	TiffType_BigTIFF     TiffType = 43
)

func (TiffType) String

func (p TiffType) String() string

func (TiffType) Valid

func (p TiffType) Valid() bool

Directories

Path Synopsis
internal
fax

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL