craiyon logo

Two modern, rounded rectangular speakers, one cream and one brown, sit on a wooden table with a blurred city background.

Two modern, rounded rectangular speakers, one cream and one brown, sit on a wooden table with a blurred city background.

from PIL import Image import requests from io import BytesIO # 이미지 URL 준비 table_url = "https://shop-phinf.pstatic.net/20230518_59/ff_colorlab_1684369319816GKUqv_JPEG/thumbnail_image_65c42f12-5ee6-4d92-9956-0a3b7eaf8f4b.jpg" acton_cream_url = "https://tse3.mm.bing.net/th/id/OIP.TCsakpKp7FtNc9ZFh5IpEQHaHa?pid=Api" acton_brown_url = "https://tse1.mm.bing.net/th/id/OIP.RF8nypryBraXzgZDyfk-pwHaHa?pid=Api" # 이미지 불러오기 table_img = Image.open(BytesIO(requests.get(table_url).content)).convert("RGBA") acton_cream_img = Image.open(BytesIO(requests.get(acton_cream_url).content)).convert("RGBA") acton_brown_img = Image.open(BytesIO(requests.get(acton_brown_url).content)).convert("RGBA") # 스피커 크기 조절 (협탁 위에 어울리도록) acton_cream_img = acton_cream_img.resize((int(table_img.width * 0.6), int(table_img.width * 0.6 * acton_cream_img.height / acton_cream_img.width))) acton_brown_img = acton_brown_img.resize((int(table_img.width * 0.6), int(table_img.width * 0.6 * acton_brown_img.height / acton_brown_img.width))) # 배경(협탁 이미지) 복사 canvas_cream = table_img.copy() canvas_brown = table_img.copy() # 스피커 합성 위치 (협탁 중앙쯤) pos_x = (table_img.width - acton_cream_img.width) // 2 pos_y = (table_img.height - acton_cream_img.height) // 2 + 30 # 스피커 합성 canvas_cream.paste(acton_cream_img, (pos_x, pos_y), acton_cream_img) canvas_brown.paste(acton_brown_img, (pos_x, pos_y), acton_brown_img) # 결과 이미지 합치기 (좌: 크림, 우: 브라운) total_width = canvas_cream.width * 2 + 20 max_height = canvas_cream.height result_img = See more