def avatar_source_token(user, source):
    token_seed = (
        unicode(user.pk),
        user.username,
        user.email,
        source,
        unicode(store.avatar_file_path(user, source)),
        settings.SECRET_KEY
    )

    return sha256('+'.join(token_seed)).hexdigest()[:10]
Beispiel #2
0
def avatar_source_token(user, source):
    token_seed = (
        unicode(user.pk),
        user.username,
        user.email,
        source,
        unicode(store.avatar_file_path(user, source)),
        settings.SECRET_KEY
    )

    return sha256('+'.join(token_seed)).hexdigest()[:10]
Beispiel #3
0
def crop_source_image(user, source, crop):
    image = Image.open(store.avatar_file_path(user, source))
    crop = crop_string_to_dict(image, crop)

    crop_dimensions = [int(d * crop['ratio']) for d in crop['source']]
    cropped_image = image.crop(crop_dimensions)

    store.store_avatar(user, cropped_image)
    if source == 'tmp':
        store.store_original_avatar(user)

    return crop
def crop_source_image(user, source, crop):
    image = Image.open(store.avatar_file_path(user, source))
    crop = crop_string_to_dict(image, crop)

    crop_dimensions = [int(d * crop['ratio']) for d in crop['source']]
    cropped_image = image.crop(crop_dimensions)

    store.store_avatar(user, cropped_image)
    if source == 'tmp':
        store.store_original_avatar(user)

    return crop
Beispiel #5
0
def crop_source_image(user, source, crop):
    image = Image.open(store.avatar_file_path(user, source))
    crop = clean_crop(image, crop)

    min_size = max(settings.MISAGO_AVATARS_SIZES)
    if image.size[0] == min_size and image.size[0] == image.size[1]:
        cropped_image = image
    else:
        upscale = 1.0 / crop['zoom']
        cropped_image = image.crop((
            int(round(crop['x'] * upscale * -1, 0)),
            int(round(crop['y'] * upscale * -1, 0)),
            int(round((crop['x'] - min_size) * upscale * -1, 0)),
            int(round((crop['y'] - min_size) * upscale * -1, 0)),
        ))

    store.store_avatar(user, cropped_image)
    if source == 'tmp':
        store.store_original_avatar(user)

    return crop
Beispiel #6
0
def crop_source_image(user, source, crop):
    image = Image.open(store.avatar_file_path(user, source))
    crop = clean_crop(image, crop)

    min_size = max(settings.MISAGO_AVATARS_SIZES)
    if image.size[0] == min_size and image.size[0] == image.size[1]:
        cropped_image = image
    else:
        upscale = 1.0 / crop["zoom"]
        cropped_image = image.crop(
            (
                int(round(crop["x"] * upscale * -1, 0)),
                int(round(crop["y"] * upscale * -1, 0)),
                int(round((crop["x"] - min_size) * upscale * -1, 0)),
                int(round((crop["y"] - min_size) * upscale * -1, 0)),
            )
        )

    store.store_avatar(user, cropped_image)
    if source == "tmp":
        store.store_original_avatar(user)

    return crop