Restricting dimensions of ImageFileField data
I'm trying to make it so that the ImageFileField only accepts image files of a set dimension. I found another post on here which suggest hijacking the 'clean' met开发者_StackOverflowhod in a form, but I was wondering if it would be simpler to create a custom field type instead?
Has anyone got any code snippets which I might be able to use in order to do this? I don't want the image files to be resized at all, just uploaded as they are if they are the correct size.
Much appreciated!
This is a (recent) resizing version of the ImageField form field which sets a max size. You might be able to take inspiration from it for accepting only certain image dimensions (ie, instead of triggering resizing, make the field complain).
http://www.djangosnippets.org/snippets/1966/
Hope that helps
Steve
精彩评论