Cutycapt 和恒定图像尺寸输出

大家好,读这篇文章的人,我对 Cutycapt(html 页面转换为 PNG 图像) 有疑问。有谁知道如何“告诉”CutyCapt 输出具有恒定大小的图像,例如图像宽度必须始终为 1920 不少于不少于。我知道 CutyCpat 有参数

--min-width=

但它可能会使图像“宽度:大于 1920,这对我来说不太好。

我还尝试在 html 页面中使用带有特定宽度参数的 div 标签,但 CutyCapt 再次使图像宽度大于 1920。或者在他那里,有人可以解释一下 CutyCapt 从哪里获取输出图像尺寸参数。顺便说一句,我正在使用 CutyCapt 和 xvfb-run 。感谢您的关注。


米琪卡哇伊
浏览 47回答 1
1回答

30秒到达战场

好吧,我找到了解决方案。CutyCapt 没有“工具/参数”来制作 const img 大小(例如宽度或高度),但如果您有自己的 html 页面(您可以编辑/更新的页面),您可以使用 const 参数将其转换为图像。您需要将您的html页面(body标签内的内容)内容与container括起来。在样式标签或 css 中设置该容器的参数,例如 width=1920px;查看代码片段<!Doctype HTML><html>&nbsp; &nbsp; &nbsp;<head>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <meta charset="UTF-8">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <title>fixed layout</title>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <style>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* This is a comment it is not read by any browser&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; This is where the css styling goes */&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; body{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color:#000;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;background-color:#fff;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;padding:0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;margin:0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#container{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*Styling for any element with the id="container" */&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:1912px; /* The width is fixed by pixels */&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;color:#fff;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background-color:red;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </style>&nbsp; &nbsp; &nbsp;</head>&nbsp; &nbsp; &nbsp;<body>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div id="container">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p id="content"> I have a fixed width so you can only see me and the body if your monitor has enough pixels. Otherwise you will just see me, the container</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp;</body></html>&nbsp;例如,如果您需要宽度 1920,为什么选择 1912px 而不是 1920px。好吧,如果你使用 CutyCapt 将宽度为 1920 px 的 html 页面转换为 img,你的输出 img 宽度将是 1928 而不是 1920,这就是为什么你需要 8px 少的宽度参数。我认为如果您更改 #container 中的填充参数,则无需将参数宽度设置为比所需少 8px。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5