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: Unable to decode DNG files with external package #57746

Open
mholt opened this issue Jan 11, 2023 · 3 comments
Open

x/image/tiff: Unable to decode DNG files with external package #57746

mholt opened this issue Jan 11, 2023 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mholt
Copy link

mholt commented Jan 11, 2023

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

$ go version
go version go1.19.1 linux/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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/matt/.cache/go-build"
GOENV="/home/matt/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/matt/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/matt/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1397311274=/tmp/go-build -gno-record-gcc-switches"

What did you do?

The x/image/tiff package is in conflict with DNG decoder packages because it registers its format on init(), even though TIFF files and DNG files look similar.

I suppose one of these solutions must work:

  • x/image/tiff should support decoding DNG files
  • or it should use a more specific "magic" header if possible
  • or it should not register its format on init().

What did you expect to see?

I expect that I should be able to call image.Decode() on a DNG file and have it successfully work using a registered DNG decoder.

The problem is that DNG and TIFF files look similar at the beginning, so registering both the TIFF and DNG formats will cause the TIFF to be used instead of DNG.

I'm not actually decoding TIFF files, but I'm using TIFF APIs because DNG shares some in common.

What did you see instead?

"tiff: unsupported feature: color model"

Currently it doesn't seem possible to use image.Decode() for DNG files.

@gopherbot gopherbot added this to the Unreleased milestone Jan 11, 2023
@seankhliao
Copy link
Member

Given how the DNG package you linked has the author saying

// DNG is a bastardized TIFF file.
// This package is a stripped back version of golang.org/x/image/tiff.

perhaps it should be on the DNG package to also support tiffs, or choose a more specific header?

@seankhliao
Copy link
Member

no longer registering by default would be a breaking change.

cc @nigeltao

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 11, 2023
@mholt
Copy link
Author

mholt commented Jan 11, 2023

If DNG is "basically" a TIFF file, I think my favorite solution would be for x/image/tiff to support DNG 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants