스토리 이미지 생성 기능 추가 및 관련 코드 수정
This commit is contained in:
parent
60011917bc
commit
8bc993d8d8
3 changed files with 28 additions and 5 deletions
|
|
@ -64,6 +64,29 @@ def 얻기(MLSV_YMD:str):
|
||||||
|
|
||||||
print("🍲 | Meal Info Image Saved")
|
print("🍲 | Meal Info Image Saved")
|
||||||
|
|
||||||
|
def 스토리_얻기(MLSV_YMD:str):
|
||||||
|
# 1:1 to 9:16 temp/{MLSV_YMD}.png
|
||||||
|
|
||||||
|
사진 = Image.open(f"{ROOT}temp/{MLSV_YMD}.png")
|
||||||
|
가로, 세로 = 사진.size
|
||||||
|
비율 = 9 / 16
|
||||||
|
가로_비율 = 가로 / 세로
|
||||||
|
if 가로_비율 < 비율:
|
||||||
|
새_가로 = int(세로 * 비율)
|
||||||
|
새_세로 = 세로
|
||||||
|
새_사진 = Image.new("RGB", (새_가로, 새_세로), (10, 10, 10))
|
||||||
|
사진 = 사진.resize((int(가로 * 0.85), int(세로 * 0.85)), Image.LANCZOS)
|
||||||
|
새_사진.paste(사진, (int((새_가로 - 사진.width) / 2), int((새_세로 - 사진.height) / 2)))
|
||||||
|
else:
|
||||||
|
새_가로 = 가로
|
||||||
|
새_세로 = int(가로 / 비율)
|
||||||
|
새_사진 = Image.new("RGB", (새_가로, 새_세로), (10, 10, 10))
|
||||||
|
사진 = 사진.resize((int(가로 * 0.85), int(세로 * 0.85)), Image.LANCZOS)
|
||||||
|
새_사진.paste(사진, (int((새_가로 - 사진.width) / 2), int((새_세로 - 사진.height) / 2)))
|
||||||
|
|
||||||
|
새_사진.save(f'temp/{MLSV_YMD}-story.png')
|
||||||
|
print("🍲 | Story Info Image Saved")
|
||||||
|
|
||||||
def 디스코드(MLSV_YMD:str):
|
def 디스코드(MLSV_YMD:str):
|
||||||
|
|
||||||
오늘급식 = 급식_정보_얻기(MLSV_YMD)
|
오늘급식 = 급식_정보_얻기(MLSV_YMD)
|
||||||
|
|
|
||||||
|
|
@ -17,20 +17,19 @@ print("🍲 | Getting Meal Info Image")
|
||||||
lib.얻기(MLSV_YMD)
|
lib.얻기(MLSV_YMD)
|
||||||
#lib.얻기(MLSV_YMD)
|
#lib.얻기(MLSV_YMD)
|
||||||
|
|
||||||
path = f"temp/{MLSV_YMD}.png"
|
|
||||||
print(f"🍲 | Meal Info Image Saved : {path}")
|
|
||||||
|
|
||||||
print("📸 | Uploading Story")
|
print("📸 | Uploading Story")
|
||||||
cl.photo_upload_to_story(
|
cl.photo_upload_to_story(
|
||||||
path=path,
|
path=f"temp/{MLSV_YMD}.png",
|
||||||
caption=f"#인천상정중학교 #상정중학교 #급식 \n{MLSV_YMD}일자 급식",
|
caption=f"#인천상정중학교 #상정중학교 #급식 \n{MLSV_YMD}일자 급식",
|
||||||
extra_data = {'is_paid_partnership' : False}
|
extra_data = {'is_paid_partnership' : False}
|
||||||
)
|
)
|
||||||
print("📸 | Story Uploaded")
|
print("📸 | Story Uploaded")
|
||||||
|
|
||||||
|
lib.스토리_얻기(MLSV_YMD)
|
||||||
print("🖼️ | Uploading Post")
|
print("🖼️ | Uploading Post")
|
||||||
cl.photo_upload(
|
cl.photo_upload(
|
||||||
path,
|
f"temp/{MLSV_YMD}-story.png",
|
||||||
caption=f"#인천상정중학교 #상정중학교 #급식 \n{MLSV_YMD}일자 급식",
|
caption=f"#인천상정중학교 #상정중학교 #급식 \n{MLSV_YMD}일자 급식",
|
||||||
extra_data = {'is_paid_partnership' : False}
|
extra_data = {'is_paid_partnership' : False}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
MLSV_YMD = str((datetime.now() + timedelta(days=0)).strftime('%Y%m%d'))
|
MLSV_YMD = str((datetime.now() + timedelta(days=0)).strftime('%Y%m%d'))
|
||||||
|
|
||||||
lib.얻기("20241108")
|
lib.얻기("20241108")
|
||||||
|
lib.스토리_얻기("20241108")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue