Add load image, Dockerfile e requirements

This commit is contained in:
dede-
2023-09-17 21:55:40 -03:00
parent 74a1a8458e
commit 84df834b82
5 changed files with 88 additions and 22 deletions

View File

@@ -1,5 +1,7 @@
from wand.image import Image
from static.image_helper import ImageHelper
def box_blur_image_separable(image, blurred_image, radius_x, radius_y):
pixels = image.get_pixels()
@@ -30,28 +32,38 @@ def box_blur_image_separable(image, blurred_image, radius_x, radius_y):
return blurred_image
def save_image(file_stream):
with open("image.png", "wb") as file:
file.write(file_stream.read())
file.close()
class ImageService:
def __init__(self):
pass
def box_blur_image(self, image, radius):
def box_blur_image(self, img, radius):
temp_path = 'temp_image.png'
image.save(temp_path)
img.save(temp_path)
with Image(filename=temp_path) as img:
img.blur(radius, 2) # Apply blur directly to the image object
img.blur(radius, 2)
blurred_temp_path = 'blurred_temp_image.png'
img.save(filename=blurred_temp_path) # Save the modified image
img.save(filename='blurred_temp_image.png')
return blurred_temp_path
def save_image(self, file_stream):
with open("image.png", "wb") as file:
file.write(file_stream.read())
file.close()
def get_simple_image(self):
return Image(filename='path_to_simple_image.png')
with ImageHelper.SimpleImage as img:
img = ImageHelper.SimpleImage
simple_image = 'simple_image.png'
img.save(filename='simple_image.png')
return simple_image
def get_big_image(self):
return Image(filename='path_to_big_image.png')
with ImageHelper.BigImage as img:
img = ImageHelper.BigImage
big_image = 'big_image.png'
img.save(filename='big_image.png')
return big_image