Buffer size in get_image_dimensions too small
|Reported by:||seph||Owned by:||nobody|
|Severity:||Keywords:||ImageField, get_image_dimensions, buffer|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The buffer size inside django/core/files/images.py, get_image_dimensions is currently set to 1024 bytes in trunk.
This wouldn't nescessarily mean many iterations if the image can be identified through PIL without loading the entire image. But using a 32 MB TIFF will result in excessive CPU usage due to the large amounts of iterations needed to reach 32 MB (somewhere over 30.000 iterations). This effectively means the ImageField which uses get_image_dimensions cannot operate under these conditions.
Increasing this buffer from 1K to 16K would mean a lot for general performance of the ImageField.
My current workaround is moneypatching the function to override the buffer size, but some kind of fix or setting would really be appreciated.
Change History (6)
Changed 5 years ago by seph
comment:1 Changed 5 years ago by jacob
- milestone changed from 1.1 to 1.2
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:4 Changed 4 years ago by ubernostrum
- Resolution set to duplicate
- Status changed from new to closed