ImageField does not set width/height_field using 'actual' file
|Reported by:||Victor Andrée||Owned by:|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||no||Patch needs improvement:||yes|
As mentioned in django-developers,
ImageFieldFile.save) updates width/height_field using the 'original' (typically uploaded) file, not the one that gets saved. This means that if you don't save the same file as the one being uploaded (because you have resized it), width and height are incorrect.
The code to set width/height is in
ImageFieldFile.save, and happens before the file is saved.
I'm attaching a patch which moves this code below the save call and uses the final file to find the dimensions. I don't know much about Django internals so it might need polishing, then again, it really just moves some code down a few lines and changes one function call.
Change History (8)
comment:4 Changed 9 years ago by
|Component:||Uncategorized → File uploads/storage|
|Triage Stage:||Unreviewed → Accepted|
comment:5 Changed 9 years ago by
|Owner:||Marty Alchin deleted|
|Patch needs improvement:||set|
|Status:||assigned → new|