Commit Graph

26 Commits

Author SHA1 Message Date
Benny Siegert
6af46c2009 tiff: reject IFDs whose data is longer than int.
Fixes golang/go#10596

Change-Id: Ib5035569e84c67868c7f278281620f6c9b11b470
Reviewed-on: https://go-review.googlesource.com/9378
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-05-04 03:48:26 +00:00
Nigel Tao
b2f48f3f51 tiff: don't panic on reading short block data.
Fixes golang/go#10394

Change-Id: I12621650f0c21579047497407ca2745febe4521b
Reviewed-on: https://go-review.googlesource.com/9278
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-28 01:06:15 +00:00
Håvard Haugen
72a6583050 x/image/tiff: fix division by zero when decoding empty image
Return a zero width or zero height image of the appropriate type.

Fixes golang/go#10393.

Change-Id: I3aa7b6125447726600fb072ce1e8682373ce2a57
Reviewed-on: https://go-review.googlesource.com/9182
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-28 00:39:31 +00:00
chai2010
f681781743 tiff: fix shadowed err variable.
Fixes golang/go#10395

Change-Id: Ice768df7bb0bdac979d49328bfdf0d6713a1e7c3
Reviewed-on: https://go-review.googlesource.com/9264
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-24 01:40:59 +00:00
David Symonds
0351284b2d image: add import comments.
Change-Id: I2d3a1d002ad43af24cd8b451a2cae4c217482675
Reviewed-on: https://go-review.googlesource.com/1237
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-09 22:43:18 +00:00
Andrew Gerrand
2e99ef522d go.image: use golang.org/x/... import paths
LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/169090043
2014-11-10 08:52:14 +11:00
Nigel Tao
34eb6b7c8b go.image/tiff: remove unreachable code.
This makes "go vet code.google.com/p/go.image/..." happy.

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/103630047
2014-06-30 11:43:54 +10:00
Nigel Tao
a1da419f1a go.image/tiff: fix (TIFF-specific) LZW decompression.
The blue-purple-pink.lzwcompressed.tiff image was created by
"bmp2tiff -c lzw".

LGTM=djd
R=djd
CC=bsiegert, golang-codereviews
https://golang.org/cl/105750045
2014-06-02 14:51:51 +10:00
Nigel Tao
2bda575717 go.image/tiff/lzw: fork the standard library's compress/lzw package.
This CL has no code changes. Future CLs will modify the code to
implement TIFF's LZW instead of the standard LZW.

LGTM=bradfitz
R=djd, bradfitz
CC=golang-codereviews
https://golang.org/cl/105750044
2014-06-02 13:56:21 +10:00
Patrick Riley
38c1f4ffe8 go.image/tiff: Support missing Compression tag
no_compress.tiff is no_rps.tiff that was read in by go.image/tiff and written out again (with a hack to avoid creating the Compression tag on the way out).

$ tiffdump no_compress.tiff
no_compress.tiff:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 968 (0x3c8) next 0 (0)
ImageWidth (256) SHORT (3) 1<16>
ImageLength (257) SHORT (3) 1<15>
BitsPerSample (258) SHORT (3) 4<8 8 8 8>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<8>
SamplesPerPixel (277) SHORT (3) 1<4>
RowsPerStrip (278) SHORT (3) 1<15>
StripByteCounts (279) LONG (4) 1<960>
XResolution (282) RATIONAL (5) 1<72>
YResolution (283) RATIONAL (5) 1<72>
ResolutionUnit (296) SHORT (3) 1<2>
ExtraSamples (338) SHORT (3) 1<2>

LGTM=bsiegert, nigeltao
R=bsiegert, nigeltao
CC=golang-codereviews
https://golang.org/cl/95930044
2014-05-12 16:41:44 +10:00
ChaiShushan
420d421738 go.image/tiff: encoder fix non LZW Predictor and Paletted SamplesPerPixel and non RGB ExtraSamples.
TIFF6.0 Spec:
Page 31: ExtraSamples can only included in RGB mode image.
Page 39, SamplesPerPixel is usually 1 for bilevel, grayscale, and palette-color images.
Page 64, Currently Predictor field is used only with LZW.

Fixes golang/go#6421.

R=bsiegert, nigeltao, gbulmer
CC=golang-dev
https://golang.org/cl/13779043
2013-09-22 11:21:53 +10:00
ChaiShushan
b2d744f611 go.image/tiff: support 16bit RGB
R=nigeltao, bsiegert
CC=golang-dev
https://golang.org/cl/13736044
2013-09-18 17:16:05 +10:00
ChaiShushan
e39b2394e5 go.image/tiff: encoder support Gray/Gray16/Paletted format
Use these commands to generate testdata:

# TIFF Tools
tiff2bw    video-001.tiff video-001-gray.tiff
tiffmedian video-001.tiff video-001-paletted.tiff

# ImageMagick
convert -depth 16 video-001.tiff      video-001-16bit.tiff
convert -depth 16 video-001-gray.tiff video-001-gray-16bit.tiff

R=nigeltao, bsiegert
CC=golang-dev
https://golang.org/cl/13243047
2013-09-13 17:42:53 +10:00
ChaiShushan
de306d5329 go.image/tiff: decoder support tiled tiff format
Use these commands to generate testdata:
tiffcp -s -r 64 video-001.tiff video-001-strip-64.tiff
tiffcp -t -l 64 -w 64 video-001.tiff video-001-tile-64x64.tiff

R=golang-dev, nigeltao, bsiegert
CC=golang-dev
https://golang.org/cl/13453043
2013-09-06 20:07:58 +10:00
ChaiShushan
822abc7ef1 go.image/tiff: add missing encoder to pkg doc
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/13302045
2013-09-02 13:29:55 +10:00
Benny Siegert
26936f5590 go.image/tiff: Support reading 16-bit gray images.
Fixes golang/go#5866.

R=nigeltao
CC=golang-dev
https://golang.org/cl/11920043
2013-07-30 15:02:33 +10:00
Benny Siegert
d165204442 go.image/tiff: support for writing compressed images.
Only Deflate compression is supported for now.

R=nigeltao, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6866051
2012-12-12 13:24:12 +11:00
Benny Siegert
41cf08abcf tiff: support writing files with differencing predictor.
This will make more sense after implementing compression.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6567077
2012-10-03 10:11:21 +10:00
Benny Siegert
5198c64fc9 tiff: new Options parameter for Encode.
No functional change at the moment but it will allow choosing
the compression type.

This is an incompatible, user-visible change. To get the old
behavior, callers of tiff.Encode need to add ", nil" as the
last parameter.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6479044
2012-08-23 20:16:03 +10:00
Benny Siegert
c35a1ecb6c go.image/tiff: use optimized routines for RGBA and NRGBA
Performance for an RGBA image:

benchmark          old ns/op    new ns/op    delta
BenchmarkEncode      1633495         7897  -99.52%

benchmark           old MB/s     new MB/s  speedup
BenchmarkEncode        37.83      7824.96  206.85x

NRGBA images are now encoded as such, the spec calls it
"unassociated alpha".

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6308049
2012-06-13 10:40:38 +10:00
Benny Siegert
de792da79c go.image/tiff: add a benchmark for the encoder
The idea is to see whether it is worthwhile to implement special cases.

On my Mac Book Pro:

BenchmarkEncode	    1000	   1689656 ns/op	  36.69 MB/s

R=nigeltao, minux.ma
CC=golang-dev
https://golang.org/cl/6278050
2012-06-07 09:41:24 +10:00
Nigel Tao
20e9620e99 go.image/tiff: simplify encoding.
R=bsiegert
CC=golang-dev
https://golang.org/cl/5738044
2012-03-07 10:32:33 +11:00
Benny Siegert
f594c3aad5 go.image/tiff: initial support for writing TIFF images
The basic functionality works. Features to add in future CLs:

- compression
- fast paths for image formats that can be directly expressed in TIFF,
  such as RGBA, NRGBA and maybe Gray and Paletted.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5694051
2012-03-05 11:45:47 +11:00
Benny Siegert
324e6dabf0 go.image/tiff: optimize reading uncompressed files from a tiff.buffer.
In case the image is read via a tiff.buffer, avoid copying the
data strip before decoding it. Remove corresponding TODO.
Speeds up reading uncompressed images (which is the common case)
and uses much less memory.

benchmark                      old ns/op    new ns/op    delta
BenchmarkDecodeCompressed        4619438      4630774   +0.25%
BenchmarkDecodeUncompressed       260809       219875  -15.70%

R=nigeltao
CC=golang-dev
https://golang.org/cl/5683050
2012-02-21 11:25:19 +11:00
Nigel Tao
996c335c4a go.image/{bmp,tiff}: move tiff/testdata to testdata.
Add a "compare to golden PNG" test for BMP and TIFF.

R=rsc
CC=golang-dev
https://golang.org/cl/5601054
2012-01-31 14:02:27 +11:00
Nigel Tao
cc3e6234e7 go.image: initial code.
Manual edits to README.
Moved from main Go repository, deleted Makefiles.

Tested with go test code.google.com/p/go.image/...

Fixes golang/go#2797.

R=rsc, rsc, r
CC=golang-dev
https://golang.org/cl/5593053
2012-01-31 11:32:50 +11:00