Beispiel #1
0
def PictureToProto(record, full=False, use_png=False):
    ret = models_pb2.Image()
    if use_png:
        ret.url = record.resized_png.url
        ret.thumbnail_url = record.thumbnail_png.url
    else:
        ret.url = record.resized.url
        ret.thumbnail_url = record.thumbnail.url
    ret.original_url = record.image.url
    # TODO(mikey): This can be expensive depending on the storage backend
    # (attempts to fetch image).
    #try:
    #  ret.width = record.image.width
    #  ret.height = record.image.height
    #except IOError:
    #  pass
    if record.time:
        ret.time = datestr(record.time)
    if record.caption:
        ret.caption = record.caption
    if record.user_id:
        ret.user_id = record.user.username
    if record.keg_id:
        ret.keg_id = record.keg_id
    if record.session_id:
        ret.session_id = record.session_id
    return ret
Beispiel #2
0
def BeerImageToProto(record, full=False):
    ret = models_pb2.Image()
    ret.url = record.image.url
    try:
        ret.width = record.image.width
        ret.height = record.image.height
    except IOError:
        pass
    return ret
Beispiel #3
0
def PictureToProto(record, full=False):
    ret = models_pb2.Image()
    ret.url = record.resized.url
    ret.original_url = record.image.url
    ret.thumbnail_url = record.thumbnail.url
    # TODO(mikey): This can be expensive depending on the storage backend
    # (attempts to fetch image).
    #try:
    #  ret.width = record.image.width
    #  ret.height = record.image.height
    #except IOError:
    #  pass
    return ret