h2non / bimg

Go package for fast high-level image processing powered by libvips C library
https://pkg.go.dev/github.com/h2non/bimg?tab=doc
MIT License
2.73k stars 340 forks source link

VIPS-WARNING and corrupted image #434

Open bellacbs opened 2 years ago

bellacbs commented 2 years ago

I'm converting some by compressing some images, but sometimes the alert appears:

(process:21837): VIPS-WARNING **: 10:16:34.520: read gave 149 warnings
(process:21837): VIPS-WARNING **: 10:16:34.530:

when this alert appears I notice that the compressed image has been corrupted Does anyone know how I would capture this warning of a specific image for treatment using bimg or golang?

I'm using this code:

func compress(inputName string, outPutName string) error {
    options := bimg.Options{
        Type:    bimg.JPEG,
        Width:   480,
        Quality: 80,
    }

    buffer, err := bimg.Read(inputName)
    if err != nil {
        return err
    }

    newImage, err := bimg.NewImage(buffer).Process(options)
    if err != nil {
        return err
    }

    err = bimg.Write(outPutName, newImage)
    if err != nil {
        return err
    }
    return nil
}
denarced commented 1 month ago

This occurred to me as well. For now it seems more likely to happen when I resize images on multiple goroutines at the same time.