【发布时间】:2015-12-05 11:39:06
【问题描述】:
我有一些棘手的问题,我收到了包含一些 HTML 代码的电子邮件,这些代码会生成一些 CSS 对象。对象可能有不同的大小。我想将这些对象转换为 png 图像。
我不能使用canvas2html,因为它不支持所有的CSS。目前我正在打开电子邮件,制作打印屏幕并手动保存,但这不是要走的路。我想知道你是否知道如何自动化它。
目前我正忙于编写脚本:
- 接收电子邮件
- 将 css 对象保存为 html 文件
- 在浏览器中打开文件
- 使用 powershell 制作整个屏幕的打印屏幕
- 保存到文件
- 使用 Photoshop 操作裁剪文件
我相信这应该可行(尽管我仍然有一些差距,例如如何自动将 CSS 保存到 html 文件),但我很确定必须有更好的方法来做到这一点。
示例代码:
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<body>
<i id="icon" class="fa fa-linkedin-square" style="text-shadow: rgb(48, 117, 165) 0px 0px 0px, rgb(48, 118, 167) 1px 1px 0px, rgb(49, 120, 169) 2px 2px 0px, rgb(49, 121, 171) 3px 3px 0px, rgb(50, 123, 173) 4px 4px 0px, rgb(51, 124, 175) 5px 5px 0px, rgb(51, 125, 177) 6px 6px 0px, rgb(52, 127, 179) 7px 7px 0px, rgb(52, 128, 181) 8px 8px 0px, rgb(53, 130, 183) 9px 9px 0px, rgb(53, 131, 185) 10px 10px 0px, rgb(54, 133, 187) 11px 11px 0px, rgb(55, 134, 189) 12px 12px 0px, rgb(55, 136, 191) 13px 13px 0px, rgb(56, 137, 193) 14px 14px 0px, rgb(56, 138, 195) 15px 15px 0px, rgb(57, 140, 197) 16px 16px 0px, rgb(58, 141, 199) 17px 17px 0px, rgb(58, 143, 201) 18px 18px 0px, rgb(59, 144, 203) 19px 19px 0px, rgb(59, 146, 205) 20px 20px 0px, rgb(60, 147, 207) 21px 21px 0px, rgb(60, 148, 209) 22px 22px 0px, rgb(61, 150, 211) 23px 23px 0px, rgb(62, 151, 213) 24px 24px 0px, rgb(62, 153, 215) 25px 25px 0px, rgb(63, 154, 217) 26px 26px 0px, rgb(63, 156, 219) 27px 27px 0px, rgb(64, 157, 221) 28px 28px 0px, rgb(65, 158, 223) 29px 29px 0px, rgb(65, 160, 225) 30px 30px 0px, rgb(66, 161, 227) 31px 31px 0px, rgb(66, 163, 229) 32px 32px 0px, rgb(67, 164, 231) 33px 33px 0px, rgb(67, 166, 233) 34px 34px 0px; font-size: 151px; color: rgb(255, 255, 255); height: 236px; width: 236px; line-height: 236px; border-radius: 41%; text-align: center; background-color: rgb(68, 167, 235);"></i>
</body></html>
【问题讨论】:
-
图像在电子邮件中是否正确呈现?将电子邮件的屏幕截图自动化是一个可接受的解决方案吗?
-
@sodawillow ,是的,这是可以接受的
标签: html email powershell automation