Ejemplo n.º 1
0
def resize_orderimport_files(obj):
    # Input : Order object
    # Output : None
    # Details : function will resize image size for both payment_slip,wht_slip,do
    from utility.imagelib import resize_image
    try:
        task1 = asyncio.create_task(
            resize_image(obj.payment_slip, 50, f'{obj.payment_slip.name}'))
        task2 = asyncio.create_task(
            resize_image(obj.wht_slip, 50, f'{obj.wht_slip.name}'))
        task3 = asyncio.create_task(resize_image(obj.do, 50, f'{obj.do.name}'))
        # if obj.payment_slip :
        # 	new_img = resize_image(obj.payment_slip)
        # 	if new_img:
        # 		new_img.save(obj.payment_slip.path)
        # if obj.wht_slip :
        # 	new_img = resize_image(obj.wht_slip)
        # 	if new_img:
        # 		new_img.save(obj.wht_slip.path)
        # if obj.do :
        # 	new_img = resize_image(obj.do)
        # 	if new_img:
        # 		new_img.save(obj.do.path)
    except:
        print(f'Error on {obj}')
    return True
Ejemplo n.º 2
0
def resize_order_files(obj):
    # Input : Order object
    # Output : None
    # Details : function will resize image size for both payment_slip and wht_slip
    from utility.imagelib import resize_image
    try:
        if obj.payment_slip:
            new_img = resize_image(obj.payment_slip)
            if new_img:
                new_img.save(obj.payment_slip.path)
        if obj.wht_slip:
            new_img = resize_image(obj.wht_slip)
            if new_img:
                new_img.save(obj.wht_slip.path)
    except:
        print(f'Error on {obj}')
    return True
Ejemplo n.º 3
0
async def resize_one_file(fileobj):
	from utility.imagelib import resize_image
	try:
		task = asyncio.create_task(resize_image(fileobj,50,f'{fileobj.name}'))
		resized_img = await task
		# print(f'Original size :{fileobj.size} ,New size :{resized_img.size}')
		if resized_img :
			resized_img.save(fileobj.path)
	except:
		print(f'Error on resize_one_file(Import) : {sys.exc_info()[0]}')
	return True
Ejemplo n.º 4
0
async def resize_one_file(fileobj):
    from utility.imagelib import resize_image
    try:
        task = asyncio.create_task(resize_image(fileobj, 50,
                                                f'{fileobj.name}'))
        resized_img = await task
        if resized_img:
            resized_img.save(fileobj.path)
    except:
        print(f'Error on resize_file : {fileobj}')
    return True
Ejemplo n.º 5
0
async def resize_shore_files(obj):
    # Input : Shorepass object
    # Output : None
    # Details : function will resize image size for both shorefile1 and shorefile2
    from utility.imagelib import resize_image
    try:
        # if obj.shorefile1 :
        task1 = asyncio.create_task(resize_image(obj.shorefile1))
        # if obj.shorefile2 :
        task2 = asyncio.create_task(resize_image(obj.shorefile2))

        new_img1 = await task1
        new_img2 = await task2

        if new_img1:
            new_img1.save(obj.shorefile1.path)

        if new_img2:
            new_img2.save(obj.shorefile2.path)

    except:
        print(f'Error on {obj}')
    return True