Nicer error messages for failure to load with Magick
This commit is contained in:
parent
be886f9bf9
commit
c745961f47
@ -465,14 +465,14 @@ func RenderWithMagick(path string, ro *RenderOptions, frames []IdentifyRecord) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenMagickImageFromPath(path string) (ans *ImageData, err error) {
|
func OpenImageFromPathWithMagick(path string) (ans *ImageData, err error) {
|
||||||
identify_records, err := IdentifyWithMagick(path)
|
identify_records, err := IdentifyWithMagick(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to identify image at %#v with error: %w", path, err)
|
return nil, fmt.Errorf("Failed to identify image at %#v with error: %w", path, err)
|
||||||
}
|
}
|
||||||
frames, filenames, err := RenderWithMagick(path, &RenderOptions{}, identify_records)
|
frames, filenames, err := RenderWithMagick(path, &RenderOptions{}, identify_records)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("Failed to render image at %#v with error: %w", path, err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
for _, f := range filenames {
|
for _, f := range filenames {
|
||||||
@ -484,7 +484,7 @@ func OpenMagickImageFromPath(path string) (ans *ImageData, err error) {
|
|||||||
filename := filenames[frame.Number]
|
filename := filenames[frame.Number]
|
||||||
data, err := os.ReadFile(filename)
|
data, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("Failed to read temp file for image %#v at %#v with error: %w", path, filename, err)
|
||||||
}
|
}
|
||||||
dest_rect := image.Rect(0, 0, frame.Width, frame.Height)
|
dest_rect := image.Rect(0, 0, frame.Width, frame.Height)
|
||||||
if frame.Is_opaque {
|
if frame.Is_opaque {
|
||||||
@ -512,7 +512,7 @@ func OpenImageFromPath(path string) (ans *ImageData, err error) {
|
|||||||
return nil, fmt.Errorf("Failed to load image at %#v with error: %w", path, err)
|
return nil, fmt.Errorf("Failed to load image at %#v with error: %w", path, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return OpenMagickImageFromPath(path)
|
return OpenImageFromPathWithMagick(path)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user