golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.8k stars 17.51k forks source link

x/image/tiff: invalid format: wrong number of samples for RGB #11413

Open noblehng opened 9 years ago

noblehng commented 9 years ago

This tiff file can't be decoded using "golang.org/x/image/tiff". It give out following error message:

tiff: invalid format: wrong number of samples for RGB

Test program:

package main

import (
        "bytes"
        "io/ioutil"
        "os"

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

func main() {
        data, _ := ioutil.ReadFile(os.Args[1])
        _, err := tiff.Decode(bytes.NewReader(data))
        if err != nil {
                println(err.Error())
        }   
}

Use cgo binding to libtiff decode this file without problem.

go version

go version go1.4.2 linux/amd64

tiffinfo

TIFF Directory at offset 0x83d68 (540008)
  Image Width: 300 Image Length: 450
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: RGB color
  Samples/Pixel: 4
  Rows/Strip: 1
  Planar Configuration: separate image planes
ianlancetaylor commented 9 years ago

CC @nigeltao