为了账号安全,请及时绑定邮箱和手机立即绑定

Cutycapt 和恒定图像尺寸输出

Cutycapt 和恒定图像尺寸输出

米琪卡哇伊 2023-10-30 20:49:53
大家好,读这篇文章的人,我对 Cutycapt(html 页面转换为 PNG 图像) 有疑问。有谁知道如何“告诉”CutyCapt 输出具有恒定大小的图像,例如图像宽度必须始终为 1920 不少于不少于。我知道 CutyCpat 有参数--min-width=但它可能会使图像“宽度:大于 1920,这对我来说不太好。我还尝试在 html 页面中使用带有特定宽度参数的 div 标签,但 CutyCapt 再次使图像宽度大于 1920。或者在他那里,有人可以解释一下 CutyCapt 从哪里获取输出图像尺寸参数。顺便说一句,我正在使用 CutyCapt 和 xvfb-run 。感谢您的关注。
查看完整描述

1 回答

?
30秒到达战场

TA贡献1828条经验 获得超6个赞

好吧,我找到了解决方案。CutyCapt 没有“工具/参数”来制作 const img 大小(例如宽度或高度),但如果您有自己的 html 页面(您可以编辑/更新的页面),您可以使用 const 参数将其转换为图像。您需要将您的html页面(body标签内的内容)内容与container括起来。在样式标签或 css 中设置该容器的参数,例如 width=1920px;


查看代码片段


<!Doctype HTML>

<html>

     <head>

          <meta charset="UTF-8">

          <title>fixed layout</title>

          <style>

          /* This is a comment it is not read by any browser

          This is where the css styling goes */


          body{

                   color:#000;

                   background-color:#fff;

                   padding:0;

                   margin:0;

          }


           #container{

                  /*Styling for any element with the id="container" */

                          width:1912px; /* The width is fixed by pixels */

                           color:#fff;

                            background-color:red;

            }

          </style>

     </head>

     <body>

          <div id="container">

                 <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>

          </div>

     </body>

</html> 

例如,如果您需要宽度 1920,为什么选择 1912px 而不是 1920px。好吧,如果你使用 CutyCapt 将宽度为 1920 px 的 html 页面转换为 img,你的输出 img 宽度将是 1928 而不是 1920,这就是为什么你需要 8px 少的宽度参数。我认为如果您更改 #container 中的填充参数,则无需将参数宽度设置为比所需少 8px。


查看完整回答
反对 回复 2023-10-30
  • 1 回答
  • 0 关注
  • 40 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信