Skip to content

x/image/tiff: sony .arw files decode as a 0x0 image.Gray #33708

Open
@paolobarbolini

Description

@paolobarbolini

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

$ go version
go version go1.13beta1 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Paolo\AppData\Local\go-build
set GOENV=C:\Users\Paolo\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Paolo\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Paolo\Desktop\test\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Paolo\AppData\Local\Temp\go-build477435338=/tmp/go-build -gno-record-gcc-switches

What did you do?

I installed the latest golang.org/x/image
I tried it on multiple .ARW files from different models but the issue occurs with all of them.

Sample image:
_DSC4438.zip

package main

import (
        "fmt"
        "image"
        "os"

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

func main() {
        f, err := os.Open("_DSC4438.ARW")
        if err != nil {
                panic(err)
        }

        img, format, err := image.Decode(f)
        f.Close()
        if err != nil {
                panic(err)
        }

        fmt.Printf("format: %s image: %#v width: %d height: %d", format, img, img.Bounds().Dx(), img.Bounds().Dy())
}

Result of running the code:

format: tiff image: &image.Gray{Pix:[]uint8{}, Stride:0, Rect:image.Rectangle{Min:image.Point{X:0, Y:0}, Max:image.Point{X:0, Y:0}}} width: 0 height: 0

What did you expect to see?

I expected to get an error when trying to decode the Sony .ARW raw image file, since Go doesn't know how to decode it.

What did you see instead?

The image decode function returned no errors, and the image is incorrectly decoded as a 0 pixel image:

&image.Gray{Pix:[]uint8{}, Stride:0, Rect:image.Rectangle{Min:image.Point{X:0, Y:0}, Max:image.Point{X:0, Y:0}}}

The issue seems to have been introduced by golang/image@7e034ca since golang/image@92942e4 instead returns the following error when trying to decode the raw image:

tiff: invalid format: BitsPerSample tag missing

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions