大家好,我对Cutycapt有疑问(将HTML页面转换成PNG图像)。有谁知道如何“告诉” CutyCapt输出恒定大小的图像,例如宽度必须始终为1920不小于等于图像。 我知道哪些CutyCpat具有参数
--min-width=
但是它可以使图像的“宽度:大于1920,这对我来说并不好。”
我也尝试在html页面中使用带有特定宽度参数的div标签,但CutyCapt再次使图像的宽度大于1920。 或者在他那里,有人可以从CutyCapt那里获取输出图像大小参数的地方向我解释。 顺便说一句,我在xvfb-run中使用CutyCapt。 感谢您的关注。
答案 0 :(得分:0)
我很喜欢这个解决方案。 CutyCapt没有“工具/参数”来设置const img的大小(例如宽度或高度),但是如果您拥有自己的html页面(可以编辑/更新的页面),则可以将其转换为具有const参数的图像。 您需要使用container将您的html页面(在body标签内)内容括起来。在样式标签或该容器的CSS设置参数中,例如width = 1920px;
查看代码片段
<!Doctype HTML>
<html lang="en">
<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的width参数。我认为,如果您在#container中更改填充参数,则无需将参数宽度设置为比需要的宽度少8px。