Skip to content

Commit

Permalink
Return config before create
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2brain committed Mar 9, 2024
1 parent 2ef0b89 commit e33a90d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions decode_dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func decodeDynamic(r io.Reader, configOnly bool) (image.Image, image.Config, err
cfg.Height = heifImageHandleGetHeight(handle)
cfg.ColorModel = color.NRGBAModel

if configOnly {
return nil, cfg, nil
}

img := &heifImage{}
e = heifImageCreate(cfg.Width, cfg.Height, heifColorspaceRgb, heifChromaInterleavedRgba, &img)
if e.Code != 0 {
Expand All @@ -58,10 +62,6 @@ func decodeDynamic(r io.Reader, configOnly bool) (image.Image, image.Config, err
return nil, cfg, ErrDecode
}

if configOnly {
return nil, cfg, nil
}

options := heifDecodingOptionsAlloc()
options.ConvertHdrTo8bit = 1
defer heifDecodingOptionsFree(options)
Expand Down

0 comments on commit e33a90d

Please sign in to comment.