code: def to_python(self, data):
          
          f = super(ImageFormField, self).to_python(data)
          if f is None:
              return None
  
          # We need to get a file raw data to validate it.
          if hasattr(data, 'temporary_file_path'):
              with open(data.temporary_file_path(), 'rb') as fp:
                  raw_data = fp.read()
          elif hasattr(data, 'read'):
              raw_data = data.read()
          else:
              raw_data = data['content']
  
          if not default.engine.is_valid_image(raw_data):
              raise forms.ValidationError(self.default_error_messages['invalid_image'])
          if hasattr(f, 'seek') and callable(f.seek):
              f.seek(0)
  
          return f
docs: Checks that the file-upload field data contains a valid image (GIF,
          JPG, PNG, possibly others -- whatever the engine supports).