canvas绘制图像 保存
I share my blog posts on Twitter, and there’s been a time when I entertained myself drawing drawing an image for each blog post.
我在Twitter上分享我的博客文章,有时候我会为每个博客文章绘制图像来娱乐自己。
I set up Hugo so it uses an image named banner.png
or banner.jpg
stored in the post folder to be used as the Open Graph image, like this:
我设置了Hugo,以便它使用存储在post文件夹中的名为banner.png
或banner.jpg
的图像用作“打开图形”图像,如下所示:
<meta property="og:image" content="https://flaviocopes.com/axios/banner.png" />
If a post has no image, I show my avatar instead:
如果帖子没有图片,我会显示我的头像:
<meta property="og:image" content="https://flaviocopes.com/img/avatar.png" />
There’s a problem: I stopped making those custom banner images a long time ago, and most of my posts don’t have a banner.
有一个问题:很久以前,我不再制作那些自定义的横幅图像,而且我的大多数帖子都没有横幅。
They all look the same on Twitter:
它们在Twitter上看起来都一样:
There’s no way I can make like 500 banner images at hand. I’ve had this thought of programmatically generating them since I saw Indie Hackers generating those images for forum blog posts (a great idea):
我不可能手头上制作500张横幅图像。 我曾经想到过以编程方式生成它们的想法,因为我看到独立黑客为论坛博客帖子生成了这些图像(一个好主意):
So after stumbling upon a nice inspiration for a ba