scardine / image_size

Get image width and height given a file path using minimal dependencies (no need for PIL, libjpeg, libpng, etc)
MIT License
153 stars 45 forks source link

Variables `w` and `h` possibly unassigned during JPEG image size computation #17

Open laclouis5 opened 1 year ago

laclouis5 commented 1 year ago

I'm using this code in a project and while running the linter with type checking enabled (Pylint) I found what look like an error in the decoding of the image size of the JPEG variant here:

https://github.com/scardine/image_size/blob/fb25377f42fc6c90c280462a87a41cf20cc2ac0e/get_image_size.py#L144-L171

More specifically, if the if branch at line 156 is not triggered, the variables h and w are not assigned any value. Thus, line 164 and 165 fails and the image size cannot be computed. Is there something missing in the else branch?