Dances with AI

연하장 만들기 (feat. ChatGPT)

출처 : ChatGPT로 한글과 한자가 적힌 카드 만들기

ChatGPT 를 활용해 연하장(새해 인사가 들어간 이미지)을 만드는 기술블로그의 포스팅을 보고 저도 한번 똑같이 따라해봤습니다. 역시 전문가들은 시도 자체가 다르군요. 존경합니다.

첫번째 프롬프트를 전달합니다. Use Dall.E: draw korean ink painting style landscape image, sephia tone, minimalism DALL·E 2023-12-28 18.27.08 - A minimalist Korean ink painting style landscape, rendered in sepia tones. The composition should be sparse, emphasizing the elegance of empty space,

조선일보에서 제공하는 조선100년체 폰트를 파일로 첨부하며 두번째 프롬프트를 전달합니다. 몇 번 분석실패하더니 아래와 같은 결과를 냅니다. Use Data Analysis: add text '새해 복 많이 받으세요' on top 20% of the generated image above in black, center in horizontal alignment. use the attached font. modified korean ink painting with text

아래는 ChatGPT가 데이터 분석에 사용한 코드입니다.

# Text to be added
text = "새해 복 많이 받으세요"

# Reopen the image
image = Image.open(image_path)

# Setup font and calculate text size and position
font_size = 60
font = ImageFont.truetype(font_path, font_size)
draw = ImageDraw.Draw(image)
text_width, text_height = draw.textsize(text, font=font)
image_width, image_height = image.size
x = (image_width - text_width) / 2
y = image_height * 0.1  # 10% from the top

# Add text to the image
draw.text((x, y), text, font=font, fill="black")

# Save the modified image
modified_image_path = '/mnt/data/modified_korean_ink_painting_with_text.png'
image.save(modified_image_path)
modified_image_path

ChatGPT 에게 한글과 관련한 요청을 하면 제대로 표시하지 못하는 문제가 있었는데 이런 식으로 처리할 수도 있군요. 신기한 녀석입니다.

  • #ChatGPT
  • #연하장