예제 #1
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]
예제 #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]
예제 #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
예제 #4
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
예제 #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
예제 #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