[sync] updated post events
This commit is contained in:
1 parent
10dd3d6316
commit
b98a809543
8 files changed
+41
-37
No files matched your search
@@ -3,7 +3,7 @@ import os
|
||||
from PIL import Image
|
||||
|
||||
from utils.hash import hash_file
|
||||
from utils.image import resize
|
||||
# from utils.image import resize
|
||||
from utils.image.resize import optimize, thumbnail, orient
|
||||
|
||||
|
||||
@@ -62,14 +62,11 @@ def create_image(file, sizes, url_fn, output_dir, skip_processing=False):
|
||||
def process_image(input_file, output_file, size):
|
||||
size_name, width, height = size
|
||||
|
||||
image = read_image(input_file)
|
||||
image_width, image_height = image.size
|
||||
if image_height > image_width:
|
||||
width, height = height, width
|
||||
|
||||
if size_name == 'original':
|
||||
thumb = optimize(input_file, output_file, quality=90)
|
||||
return optimize(input_file, output_file, quality=90)
|
||||
else:
|
||||
thumb = thumbnail(input_file, output_file, (width, height))
|
||||
|
||||
return thumb
|
||||
image = read_image(input_file)
|
||||
image_width, image_height = image.size
|
||||
if image_height > image_width:
|
||||
width, height = height, width
|
||||
return thumbnail(input_file, output_file, (width, height))
|
||||
@@ -10,13 +10,13 @@ import utils.image
|
||||
|
||||
|
||||
def thumbnail(src, dest, size, ext=None):
|
||||
image_magick_resize(src, dest, size, quality=85)
|
||||
return utils.image.read_image(dest)
|
||||
# image_magick_resize(src, dest, size, quality=85)
|
||||
# return utils.image.read_image(dest)
|
||||
|
||||
# image = read_image(src)
|
||||
# image.thumbnail(size)
|
||||
# image.save(override_extension(dest, ext))
|
||||
# return image
|
||||
image = utils.image.read_image(src)
|
||||
image.thumbnail(size)
|
||||
image.save(override_extension(dest, ext))
|
||||
return image
|
||||
|
||||
|
||||
def optimize(src, dest, quality=85, ext=None):
|
||||
@@ -39,17 +39,15 @@ def crop(src, dest, size):
|
||||
crop_options['width'] = width
|
||||
crop_options['height'] = height
|
||||
|
||||
crop = SmartCrop()
|
||||
result = crop.crop(image.copy(), crop_options)
|
||||
crop_instance = SmartCrop()
|
||||
result = crop_instance.crop(image.copy(), crop_options)
|
||||
|
||||
box = (result['topCrop']['x'],
|
||||
result['topCrop']['y'],
|
||||
result['topCrop']['x'] + result['topCrop']['width'],
|
||||
result['topCrop']['y'] + result['topCrop']['height'])
|
||||
|
||||
i = utils.image\
|
||||
.read_image(src)\
|
||||
.crop(box)
|
||||
i = utils.image.read_image(src).crop(box)
|
||||
i.thumbnail(size, Image.ANTIALIAS)
|
||||
i.save(dest)
|
||||
|
||||
|
||||
Reference in new issue
Block a user