<s> """<STR_LIT>""" <EOL> import logging <EOL> import pickle <EOL> from PIL import Image <EOL> from . logutils import log_start <EOL> from . constants import RelativePosition <EOL> from . workflow import ( <EOL> post_process , image_watermark , resize , preprocess <EOL> ) <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> @ log_start ( logger ) <EOL> def job_function ( input_img_path , output_dir , wm_img = None , <EOL> output_size = None , output_format = None , <EOL> wm_position = RelativePosition . BOTTOM_RIGHT , raise_errors = False <EOL> ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> input_img = preprocess ( input_img_path ) <EOL> output_img = input_img <EOL> posx , posy = RelativePosition . split ( wm_position ) <EOL> if wm_img is not None : <EOL> wm_img = pickle . loads ( wm_img ) <EOL> output_img = image_watermark ( <EOL> input_img , wm_img , posx = posx , posy = posy ) <EOL> if output_size : <EOL> percent = None <EOL> width = None <EOL> height = None <EOL> if len ( output_size ) == <NUM_LIT:1> : <EOL> percent = output_size [ <NUM_LIT:0> ] <EOL> else : <EOL> width , height = output_size <EOL> output_img = resize ( output_img , percent = percent , width = width , <EOL> height = height , resample = Image . ANTIALIAS , <EOL> keep_filename = True ) <EOL> post_process ( output_img , output_dir , output_format ) <EOL> except Exception as e : <EOL> logger . critical ( "<STR_LIT:%s>" % e ) <EOL> if raise_errors : <EOL> raise </s>
