Skip to content

Instantly share code, notes, and snippets.

@leejh3224
Created March 7, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejh3224/d2b7de6c082bf6f55e389ccb87dfdc5d to your computer and use it in GitHub Desktop.
Save leejh3224/d2b7de6c082bf6f55e389ccb87dfdc5d to your computer and use it in GitHub Desktop.
import sys
import os
import fnmatch
from PIL import Image
imageSource = os.path.join(
"C:\\", "Users", "stern", "Google 드라이브", "기타", "Goodnotes4Export"
)
outputPath = os.path.join(
"C:\\", "Users", "stern", "Google 드라이브", "기타", "output"
)
lastPage = len(fnmatch.filter(os.listdir(imageSource), "*.png"))
imageNames = list(map(lambda x: f"{imageSource}/{x}.png", range(1, int(lastPage))))
images = list(map(Image.open, imageNames))
lastImage = Image.open(f"{imageSource}/{lastPage}.png")
for idx, img in enumerate(images):
width, height = img.size
width_last, _ = lastImage.size
original_name = f"{idx + 1}.png"
out_image = Image.new("RGB", (width + width_last, height))
out_name = f"{outputPath}/r{original_name}"
out_image.paste(img, (0, 0))
out_image.paste(lastImage, (width, 0))
out_image.save(out_name)
print(f"작업완료: {int(((idx + 1) / len(images)) * 100)}%")
print("모든 작업이 완료되었습니다.")
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment