Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/image/tiff: unexpected EOF #30827

Open
coldnight opened this issue Mar 14, 2019 · 4 comments
Open

x/image/tiff: unexpected EOF #30827

coldnight opened this issue Mar 14, 2019 · 4 comments

Comments

@coldnight
Copy link

@coldnight coldnight commented Mar 14, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wh/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wh/jobs/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d7/9qx1qd7s6wb8hlmw9xtt9h_h0000gn/T/go-build488513078=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import (
	"image"
	"os"
	"log"

	_ "golang.org/x/image/tiff"
)

func main() {
	f, err := os.OpenFile("1.tif", os.O_RDONLY, 0644)

	if err != nil {
		log.Fatal(err)
	}

	img, format, err := image.Decode(f)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%v %s", img, format)
}

The image is here
1.tif.zip

What did you expect to see?

What did you see instead?

unexpected EOF

@gopherbot gopherbot added this to the Unreleased milestone Mar 14, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Apr 12, 2019

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Apr 12, 2019

Probably an expert on the format needs to decide whether the image is encoded correctly. How did you generate it?

@bsiegert

This comment has been minimized.

Copy link
Contributor

@bsiegert bsiegert commented Apr 13, 2019

The file is LZW-compressed, according to tiffinfo from libtiff:

TIFFReadDirectory: Warning, Unknown field with tag 512 (0x200) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 515 (0x203) encountered.
TIFF Directory at offset 0x112084 (1122436)
  Subfile Type: (0 = 0x0)
  Image Width: 1654 Image Length: 2340
  Resolution: 200, 200 pixels/inch
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  YCbCr Subsampling: 2, 2
  YCbCr Positioning: centered
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Rows/Strip: 2
  Planar Configuration: single image plane
  Page Number: 0-0
  Software: DocuCentre-V 2060
  Predictor: horizontal differencing 2 (0x2)

I remember there being a bug about LZW decompression resulting in "unexpected EOF" errors but that was fixed long ago.

However, the tags that tiffinfo complains about are part of the JPEG extension for TIFF (JPEGProc and JPEGRestartInterval). So AIUI, your picture is JPEG data, further compressed with LZW.

The tiff package does not support the JPEG extension right now. Sorry.

@coldnight

This comment has been minimized.

Copy link
Author

@coldnight coldnight commented Apr 14, 2019

@bsiegert Thanks for your answer, and I have use libtiff instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.