Closed reward-rabieth closed 1 year ago
Hmm, this is a little bit weird.
imgHeightWidthRatio := float32(img.Metadata().Height) / float32(img.Metadata().Width)
, imgHeightWidthRatio
seems can only be zero when img.Metadata().Height
is zero, and normal image cannot have zero in height.
Do you have an example image that could lead to this problem?
Thank you for your response. No, I don't have an example image that could lead to this problem. It was indeed just an idea and not based on a specific image-related issue. I appreciate your clarification, and I'm satisfied with the explanation you provided.
https://github.com/webp-sh/webp_server_go/blob/d9da7f3cd3c1a13cce368a81e15ecab162fd7afd/encoder/encoder.go#L43C4-L48C3
Check if imgHeightWidthRatio is not zero before dividing.
Handle the case where imgHeightWidthRatio is zero (avoid division by zero) You can log an error or take appropriate action