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.65k stars 337 forks source link

VIPS-WARNING and corrupted image #434

Open bellacbs opened 1 year ago

bellacbs commented 1 year 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
}