Post

gif 꾸미기

갑자기 제로베이스 로고와 어떤 gif 사진을 합쳐 내 이니셜을 새긴 gif를 만들어보고 싶어서 준비해보았습니다!
사진 순서대로 형광표시한 부분 클릭하고 고치며 잘 따라 해봅시다!

1
2
3
4
5
<목차>

1. gif 파일에 글적기
2. gif + png (2)
3. gif + gif

1. gif 파일에 글적기

우선 gif 파일 아무거나 다운로드
그리고 끝나면 https://www9.lunapic.com/ 들어가기

Desktop View ⬇️
⬇️ Desktop View ⬇️
⬇️ Desktop View ⬇️
⬇️ Desktop View ⬇️
⬇️ Desktop View ⬇️
⬇️ Desktop View ⬇️
⬇️ Desktop View




2. gif + png (2개)

gif파일명을 조금 수정했습니다 그리고 제로베이스 로고.png를 합쳐봅시다

Desktop View Desktop View

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from PIL import Image, ImageSequence

# 기존 GIF 파일 경로
gif_path = "C:/Users/withj/Downloads/lunapic.gif"

# 추가할 PNG 이미지 경로
png_path = "C:/Users/withj/Downloads/test.png"

# 출력될 GIF 파일 경로
output_path = "C:/Users/withj/Downloads/zb-joonhwan.gif"

# 위치 이동할 픽셀 값
x_offset = 20  
y_offset = 10  

# 기존 GIF 열기
original_gif = Image.open(gif_path)

# PNG 이미지 열기
png_image = Image.open(png_path)

# PNG 이미지 크기 조절 (가로 100px로 예시)
png_image.thumbnail((50, 50))

# 각 프레임에 PNG 이미지 추가
result_frames = []
for frame in ImageSequence.Iterator(original_gif):
    # PNG 이미지를 현재 프레임에 추가 (가운데 위치로 이동)
    paste_x = (frame.width - png_image.width) // 2
    paste_y = 0  # Set Y coordinate to 0 for the top
    frame.paste(png_image, (paste_x + x_offset, paste_y + y_offset), png_image)

    # 결과 프레임 추가
    result_frames.append(frame.copy())

# 결과 GIF 파일 저장
result_frames[0].save(output_path, save_all=True, append_images=result_frames[1:], loop=0, duration=original_gif.info['duration'])



실행시키면 우측에 생성되고 클릭하면 이렇게 움직이는 gif 파일 생성 Desktop View




하나 더!

이렇게 합쳐보겠다

Desktop View Desktop View

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from PIL import Image, ImageSequence

# 첫 번째 GIF 파일 경로
first_gif_path = "C:/Users/withj/Downloads/joonhwan.gif"

# 두 번째 PNG 파일 경로
second_png_path = "C:/Users/withj/Downloads/jerry.png"

# 출력될 GIF 파일 경로
output_path = "C:/Users/withj/Downloads/joonk2.gif"

# 위치 이동할 픽셀 값
x_offset = 20
y_offset = 10

# 첫 번째 GIF 열기
first_gif = Image.open(first_gif_path)

# 두 번째 PNG 이미지 열기
second_png = Image.open(second_png_path)

# 두 번째 PNG 이미지 크기를 조절하여 첫 번째 GIF에 맞추기
width_ratio = 0.2  # 예시로 가로 크기를 20%로 조절
new_width = int(first_gif.width * width_ratio)
second_png = second_png.resize((new_width, new_width))

# 각 프레임에 두 번째 PNG 이미지 추가
result_frames = []
for frame1 in ImageSequence.Iterator(first_gif):
    # 두 번째 PNG 이미지를 현재 프레임에 추가 (우측 상단으로 이동)
    paste_x = frame1.width - second_png.width - x_offset
    paste_y = y_offset + 115 # 115 픽셀 아래로 이동
    
    # 결과 프레임 추가
    result_frame = frame1.copy()
    result_frame.paste(second_png, (paste_x, paste_y), second_png)
    result_frames.append(result_frame)

# 결과 GIF 파일 저장
result_frames[0].save(output_path, save_all=True, append_images=result_frames[1:], loop=0, duration=first_gif.info['duration'])

Desktop View

This post is licensed under CC BY 4.0 by the author.
3D GIF