'Updates an existing image with the registry.
:param req: wsgi Request object
:param body: Dictionary of information about the image
:param id:  The opaque internal identifier for the image
:returns: Returns the updated image information as a mapping,'

@utils.mutating
def update(self, req, id, body):

    image_data = body['image']
    from_state = body.get('from_state')
    if ((not req.context.is_admin) and ('owner' in image_data)):
        del image_data['owner']
    if ('location' in image_data):
        image_data['locations'] = [image_data.pop('location')]
    purge_props = req.headers.get('X-Glance-Registry-Purge-Props', 'false')
    try:
        sensitive_fields = ['locations', 'location_data']
        LOG.debug('Updating    image    %(id)s    with    metadata:    %(image_data)r', {'id': id, 'image_data': {k: v for (k, v) in image_data.items() if (k not in sensitive_fields)}})
        image_data = _normalize_image_location_for_db(image_data)
        if (purge_props == 'true'):
            purge_props = True
        else:
            purge_props = False
        updated_image = self.db_api.image_update(req.context, id, image_data, purge_props=purge_props, from_state=from_state, v1_mode=True)
        LOG.info(_LI('Updating    metadata    for    image    %(id)s'), {'id': id})
        return dict(image=make_image_dict(updated_image))
    except exception.Invalid as e:
        msg = (_('Failed    to    update    image    metadata.    Got    error:    %s') % encodeutils.exception_to_unicode(e))
        LOG.error(msg)
        return exc.HTTPBadRequest(msg)
    except exception.ImageNotFound:
        LOG.info(_LI('Image    %(id)s    not    found'), {'id': id})
        raise exc.HTTPNotFound(body='Image    not    found', request=req, content_type='text/plain')
    except exception.ForbiddenPublicImage:
        LOG.info(_LI('Update    denied    for    public    image    %(id)s'), {'id': id})
        raise exc.HTTPForbidden()
    except exception.Forbidden:
        LOG.info(_LI("Access    denied    to    image    %(id)s    but    returning    'not    found'"), {'id': id})
        raise exc.HTTPNotFound(body='Image    not    found', request=req, content_type='text/plain')
    except exception.Conflict as e:
        LOG.info(encodeutils.exception_to_unicode(e))
        raise exc.HTTPConflict(body='Image    operation    conflicts', request=req, content_type='text/plain')
    except Exception:
        LOG.exception((_LE('Unable    to    update    image    %s') % id))
        raise
