Baixe o app do Guru IA

Android e iOS

Estudos gerais

from PIL import Image # Abrir a imagem enviada pelo usuário input_path = "/mnt/data/file-LHq1wWA7BwNK2h9j7brr4P" output_path = "/mnt/data/squared_image.jpg" # Carregar a imagem img = Image.open(input_paimg.sizeth) # Tornar a imagem quadrada mantendo o conteúdo centralizado width, height = img.size if width != height: size = max(width, height) new_img = Image.new("RGB", (size, size), (255, 255, 255)) # Fundo branco new_img.paste(img, ((size - width) // 2, (size - height) // 2)) else: new_img = img # Salvar a nova imagem quadrada new_img.save(output_path) output_path

F

Fabricio

Feita pelo app
23/11/24