'Insert a image in database
applying field properties (size, thumbnail_size)'

def put(self, file_obj, **kwargs):

    field = self.instance._fields[self.key]
    if (hasattr(field, 'field') and isinstance(field.field, FileField)):
        field = field.field
    try:
        img = Image.open(file_obj)
        img_format = img.format
    except Exception as e:
        raise ValidationError(('Invalid    image:    %s' % e))
    progressive = (img.info.get('progressive') or False)
    if (kwargs.get('progressive') and isinstance(kwargs.get('progressive'), bool) and (img_format == 'JPEG')):
        progressive = True
    else:
        progressive = False
    if (field.size and ((img.size[0] > field.size['width']) or (img.size[1] > field.size['height']))):
        size = field.size
        if size['force']:
            img = ImageOps.fit(img, (size['width'], size['height']), Image.ANTIALIAS)
        else:
            img.thumbnail((size['width'], size['height']), Image.ANTIALIAS)
    thumbnail = None
    if field.thumbnail_size:
        size = field.thumbnail_size
        if size['force']:
            thumbnail = ImageOps.fit(img, (size['width'], size['height']), Image.ANTIALIAS)
        else:
            thumbnail = img.copy()
            thumbnail.thumbnail((size['width'], size['height']), Image.ANTIALIAS)
    if thumbnail:
        thumb_id = self._put_thumbnail(thumbnail, img_format, progressive)
    else:
        thumb_id = None
    (w, h) = img.size
    io = StringIO()
    img.save(io, img_format, progressive=progressive)
    io.seek(0)
    return super(ImageGridFsProxy, self).put(io, width=w, height=h, format=img_format, thumbnail_id=thumb_id, **kwargs)
