from PIL import Image, ImageOps
import matplotlib.pyplot as plt
# Ganti path ini dengan lokasi gambar Anda
uniform_path = "27ff9439-7152-4da2-b5e6-0213e142f726.jpeg"
face_path = "IMG_20240912_091017.jpg"
uniform_img = Image.open(uniform_path).convert("RGBA")
face_img = Image.open(face_path).convert("RGBA")
# Ubah ukuran gambar wajah agar proporsional dengan seragam
face_resized = face_img.resize((uniform_img.width, int(face_img.height * (uniform_img.width / face_img.width))))
# Crop bagian wajah (koordinat bisa Anda sesuaikan sesuai kebutuhan)
face_crop = face_resized.crop((180, 100, 480, 450))
# Ubah ukuran hasil crop agar cocok diletakkan di atas seragam
face_crop_resized = face_crop.resize((220, 260)) # ukuran perkiraan
# Gabungkan wajah dengan gambar seragam
result_img = uniform_img.copy()
result_img.paste(face_crop_resized, (150, 80), face_crop_resized)