景淮:制作个人日历-GPTs Action 实战
景淮:制作个人日历-GPTs Action 实战
景淮:制作个人日历 GPTs Action 实战 景淮:制作个人日历 GPTs Action 实战 Modified March 12, 2024 Code block Markdown Copy combined image.paste(image2, (image1.width, 0)) Save the combined image combined image path = "/mnt/data/combined image.png" combined image.save(combined image path) combined image path 四)竖版日历 💡 利用python帮我做图,把上传的第一张图片放在正副图片的下面边,然后把上传的第二张图片放在正副图片的上边。把他们拼接成一张图。确保两张图片的宽度一致,只能对上面的图片进行等比例拉伸。 Code block Markdown Copy Load the images again to reset any previous manipulation image1 = Image.open(image1 path) image2 = Image.open(image2 path) Ensure the images have the same width before concatenating and only resize the top image (image2) to match the width of the bottom image (image1) image2 = image2.resize((image1.width, image2.height image1.width // image2.width), Image.ANTIALIAS) Concatenate the images vertically combined vertical image = Image.new('RGB', (image1.width, image1.height + image2.height)) combined vertical image.paste(image2, (0, 0)) image2 on top combined vertical image.paste(image1, (0, image2.height)) image1 at the bottom Save the combined vertical image combined vertical image path = "/mnt/data/combined vertical image.png" combined vertical image.save(combined vertical image path) combined vertical image path 五)镶嵌日历 💡 利用python帮我做图,把上传的第一张图片放在整幅图片的上层,然后把上传的第二张图片放在整幅图片的下层。确保两张图片的中心点一致。把他们拼接成一张图。把下层的图片整体扩大到原图的百分之20.上层图片的透明度调整到百分之90 Code block Markdown Copy Load the images again to reset any previous manipulation image1 = Image.open(image1 path).convert("RGBA") Convert to RGBA to manage transparency image2 = Image.open(image2 path).convert("RGBA") Resize the bottom image (image2) by increasing its size by 20% factor = 1.2 20% increase new size = (int(image2.width factor), int(image2.height factor)) image2 = image2.resize(new size, Image.LANCZOS) Ensure the images have the same center point Calculate the position to paste image1 on image2 so that the centers match position = ((image2.width image1.width) // 2, (image2.height image1.height) // 2) Create a new image with transparency and the size of the bottom image combined centered image = Image.new('RGBA', image2.size) Paste the bottom image (image2) onto the transparent image combined centered image.paste(image2, (0, 0)) Adjust the transparency of the top image (image1) alpha = int(255 0.90) 90% visible image1.putalpha(alpha) Paste the top image (image1) onto the combined image, using its alpha channel as the mask combined centered image.paste(image1, position, image1) Save the combined image with centered images and transparency combined centered image path = "/mnt/data/combined centered 90 transparency image.png" combined centered image.save(combined centered image path) combined centered image path 三、提示词的编写、测试 一)初版提示词 Code block Markdown Copy Workflows: 1. 等待用户输入:提醒用户需要输入想要生成日历图片的关键词和日历的年份和月份。 记录:用户输入的关键词,记录格式如:礼品盒 记录:用户输入的年份和月份,记录格式如:2024年3月 2. 根据用户输入的关键词,对示例中的绘画提示词进行简单的修改,做为用户输入主题的绘画提示词,然后再进行绘画。 示例: 展示生成好的图片给用户,然后询问用户想要生成日历的形式(询问的同时需要展示图片的示例给用户)。 + 横版日历: 示例图: + 竖版日历: 示例图: + 镶嵌日历: 示例图: 3. 等待用户选择想要的日历格式,根据对应的格式选择对应的日历使用python进行创作。 301. 按照用户输入的年份和月份先按照下面的提示词绘制出基本日历(使用knowledge中名字为“downloa.png”的图片进行操作) 3011. 帮我knowledge中名字为“downloa.png”的图片正上方用knowledge中字体“今年也要加油鸭.ttf”写上 “ 2024 年 12 月 ”同时保证这几个字的字体大小为60px,距离整张图片的最上方100px,同时确保文字水平居中 3012. 帮我在图片中添加数字。首先使用 python 计算 2024年12月1日 是星期几。已知 2024年3月4日为星期一。注意:需要确定对应月份的天数。如一月有31天,二月如果为闰年则为29天。 如果对应的结果为星期一则填入坐标为(342, 382)的一行的右上角 如果结果为星期日则填入坐标为(1386, 382)的一行 ··· 星期一:第1列;二:第2列;三:第3列;四:第4列;五:第5列;六:第6列;日:第7列 ··· 同时确保这个月的所有天数依次写入表格中。每行写完则换到下一行继续写,直到完全写完。 表格中需要填入的数字对应坐标如下(坐标中心(0,0)为图片的右上角,单位为px,填入数字的字体大小为20px) Code block Markdown Copy combined image.paste(image2, (image1.width, 0)) Save the combined image combined image path = "/mnt/data/combined image.png" combined image.save(combined image path) combined image path Code block Markdown Copy Load the images again to reset any previous manipulation image1 = Image.open(image1 path) image2 = Image.open(image2 path) Ensure the images have the same width before concatenating and only resize the top image (image2) to match the width of the bottom image (image1) image2 = image2.resize((image1.width, image2.height image1.width // image2.width), Image.ANTIALIAS) Concatenate the images vertically combined vertical image = Image.new('RGB', (image1.width, image1.height + image2.height)) combined vertical image.paste(image2, (0, 0)) image2 on top combined vertical image.paste(image1, (0, image2.height)) image1 at the bottom Save the combined vertical image combined vertical image path = "/mnt/data/combined vertical image.png" combined vertical image.save(combined vertical image path) combined vertical image path Code block Markdown Copy Load the images again to reset any previous manipulation image1 = Image.open(image1 path).convert("RGBA") Convert to RGBA to manage transparency image2 = Image.open(image2 path).convert("RGBA") Resize the bottom image (image2) by increasing its size by 20% factor = 1.2 20% increase new size = (int(image2.width factor), int(image2.height factor)) image2 = image2.resize(new size, Image.LANCZOS) Ensure the images have the same center point Calculate the position to paste image1 on image2 so that the centers match position = ((image2.width image1.width) // 2, (image2.height image1.height) // 2) Create a new image with transparency and the size of the bottom image combined centered image = Image.new('RGBA', image2.size) Paste the bottom image (image2) onto the transparent image combined centered image.paste(image2, (0, 0)) Adjust the transparency of the top image (image1) alpha = int(255 0.90) 90% visible image1.putalpha(alpha) Paste the top image (image1) onto the combined image, using its alpha channel as the mask combined centered image.paste(image1, position, image1) Save the combined image with centered images and transparency combined centered image path = "/mnt/data/combined centered 90 transparency image.png" combined centered image.save(combined centered image path) combined centered image path Code block Markdown Copy Workflows: 1. 等待用户输入:提醒用户需要输入想要生成日历图片的关键词和日历的年份和月份。 记录:用户输入的关键词,记录格式如:礼品盒 记录:用户输入的年份和月份,记录格式如:2024年3月 2. 根据用户输入的关键词,对示例中的绘画提示词进行简单的修改,做为用户输入主题的绘画提示词,然后再进行绘画。 示例: 展示生成好的图片给用户,然后询问用户想要生成日历的形式(询问的同时需要展示图片的示例给用户)。 + 横版日历: 示例图: + 竖版日历: 示例图: + 镶嵌日历: 示例图: 3. 等待用户选择想要的日历格式,根据对应的格式选择对应的日历使用python进行创作。 301. 按照用户输入的年份和月份先按照下面的提示词绘制出基本日历(使用knowledge中名字为“downloa.png”的图片进行操作) 3011. 帮我knowledge中名字为“downloa.png”的图片正上方用knowledge中字体“今年也要加油鸭.ttf”写上 “ 2024 年 12 月 ”同时保证这几个字的字体大小为60px,距离整张图片的最上方100px,同时确保文字水平居中 3012. 帮我在图片中添加数字。首先使用 python 计算 2024年12月1日 是星期几。已知 2024年3月4日为星期一。注意:需要确定对应月份的天数。如一月有31天,二月如果为闰年则为29天。 如果对应的结果为星期一则填入坐标为(342, 382)的一行的右上角 如果结果为星期日则填入坐标为(1386, 382)的一行 ··· 星期一:第1列;二:第2列;三:第3列;四:第4列;五:第5列;六:第6列;日:第7列 ··· 同时确保这个月的所有天数依次写入表格中。每行写完则换到下一行继续写,直到完全写完。 表格中需要填入的数字对应坐标如下(坐标中心(0,0)为图片的右上角,单位为px,填入数字的字体大小为20px) 302. 按照要求合并日历:根据用户的选择按照对应的方法创作对应的日历 横版日历:利用python帮我做图,把刚才Dalle 3绘制的图片放在整幅图片的左边,然后刚才生成的基本日历图片放在整幅图片的右边。把他们拼接成一张图。确保两张图的高度一致。 示例代码: 竖版日历:利用python帮我做图,把刚才Dalle 3绘制的图片放在整幅图片的上边,然后把刚才制作的基本日历放在整幅图片的上边。把他们拼接成一张图。确保两张图片的宽度一致,只能对上面的图片进行等比例拉伸。 + 代码示例: 镶嵌日历:利用python帮我做图,把刚才制作的基本日历图片放在整幅图片的上层,然后把Dalle 3绘制的图片放在整幅图片的下层。确保两张图片的中心点一致。把他们拼接成一张图。把下层的图片整体扩大到原图的百分之20.上层图片的透明度调整到百分之90. + 代码示例: Code block Markdown Copy 帮我使用python画一个7 7的日历表格。其中第一行为70px,其他行都为100px,每个方格的宽度统一为100px。 在日历表格的四周边距分别为:top 180px,left 100px,right 100px,bottom 50px。背景颜色统一为白色。表格的外边框为 3px,内边框为1px。表格边框的颜色为浅蓝色 帮我重新调整下 Code block Markdown Copy 在表格的第一行的七个格子中,分别用我上传的字体写上“一、二、三、四、五、六、日”,要求在每个格子中垂直居中,水平居中 Code block Markdown Copy 1. 帮我在表格的正上方用我上传的字体写上 “ 2024 年 12 月 ”同时保证这几个字的字体大小为60px,距离整张图片的最上方100px,同时确保文字水平居中 2.帮我在表格中添加数字。首先使用 python 计算 2024年12月1日 是星期几。已知 2024年3月4日为星期一。注意:需要确定对应月份的天数。如一月有31天,二月如果为闰年则为29天。 如果对应的结果为星期一则填入坐标为(342, 382)的一行的右上角 如果结果为星期日则填入坐标为(1386, 382)的一行 ··· 星期一:第1列;二:第2列;三:第3列;四:第4列;五:第5列;六:第6列;日:第7列 ··· 同时确保这个月的所有天数依次写入表格中。每行写完则换到下一行继续写,直到完全写完。 表格中需要填入的数字对应坐标如下(坐标中心(0,0)为图片的右上角,单位为px,填入数字的字体大小为20px) Python import matplotlib.pyplot as plt import matplotlib.font manager as fm from PIL import Image import numpy as np Load the custom font font path = '/mnt/data/今年也要加油鸭.ttf' prop = fm.FontProperties(fname=font path) Open the uploaded calendar image img = Image.open('/mnt/data/download.png') Convert the image to a numpy array to use with matplotlib img array = np.array(img) Initialize matplotlib figure and axes fig, ax = plt.subplots(figsize=(img array.shape[1] / 100, img array.shape[0] / 100), dpi=100) Hide axes ax.axis('off') Display the calendar image ax.imshow(img array) Title text properties title text = "2024 年 12 月" title font size = 60 title y position = 100 pixels from the top of the image Add title text to the image plt.text(img array.shape[1] / 2, title y position, title text, fontproperties=prop, fontsize=title font size, ``` 效果展示 三)横版日历 💡 利用python帮我做图,把上传的第一张图片放在正副图片的左边,然后把上传的第二张图片放在正副图片的右边。把他们拼接成一张图。确保两张图的高度一致。 利用python帮我做图,把上传的第一张图片放在正副图片的左边,然后把上传的第二张图片放在正副图片的右边。把他们拼接成一张图。确保两张图的高度一致。 二) 迭代提示词