Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何缩放以适应svg中的图像_Svg_Image Resizing - Fatal编程技术网

如何缩放以适应svg中的图像

如何缩放以适应svg中的图像,svg,image-resizing,Svg,Image Resizing,我正在尝试修改svg,使它所保存的图像具有svg的全宽和全高。我该怎么做 我正在尝试将宽度和高度修改为100%,x,y修改为“0”,并将此svg属性preserveSpectratio=“xMidYMid meet” 这是初始svg: <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/

我正在尝试修改svg,使它所保存的图像具有svg的全宽和全高。我该怎么做

我正在尝试将宽度和高度修改为100%,x,y修改为“0”,并将此svg属性preserveSpectratio=“xMidYMid meet”

这是初始svg:

<?xml version="1.0" encoding="UTF-8"?>
<svg
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1512" height="1063" viewBox="0 0 1512 1063" xml:space="preserve">
    <desc>Created with Fabric.js 1.6.7</desc>
    <defs></defs>
    <g transform="translate(776.8 529.9) scale(1.01 0.95)">
        <image id="1554312687213" xlink:href="https://lobservateur-avesnois.easypubphr.fr/wp-content/uploads/sites/6/2018/11/restaurantmodel.png" x="-730.5" y="-782" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: none; fill-rule: nonzero; opacity: 1;" width="1461" height="1564" preserveAspectRatio="none"></image>
    </g>
    <g id="1554312687241" transform="translate(781 762.29)">
        <text font-family="ABeeZee" font-size="43" font-style="normal" font-weight="bold" text-decoration="normal" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1;">
            <tspan x="-164" y="13.54" fill="#ffffff">Votre entreprise</tspan>
        </text>
    </g>
    <g id="1554312687289" transform="translate(779 847.3)">
        <text font-family="ABeeZee" font-size="20" font-style="normal" font-weight="normal" text-decoration="normal" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1;">
            <tspan x="-68.31" y="6.3" fill="#ffffff">Votre adresse </tspan>
        </text>
    </g>
    <g id="1554312687296" transform="translate(776 811.17)">
        <text font-family="ABeeZee" font-size="18" font-style="normal" font-weight="normal" text-decoration="normal" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,255,255); fill-rule: nonzero; opacity: 1;">
            <tspan x="-68.83" y="5.67" fill="#ffffff">Votre telephone</tspan>
        </text>
    </g>
</svg>

使用Fabric.js 1.6.7 Votre Enterprise Votre Adrese Votre telephone创建
您遇到的问题是图像有很宽的透明边框。您要么需要使用类似Photoshop的软件来切断该边界,要么可以这样做:

正文{
填料:10vw 30vw;
}
svg{
边框:5px实心;
}

Votre企业
地址
Votre电话

您遇到的问题是图像有一个很宽的透明边框。您要么需要使用类似Photoshop的软件来切断该边界,要么可以这样做:

正文{
填料:10vw 30vw;
}
svg{
边框:5px实心;
}

Votre企业
地址
Votre电话

您需要调整查看框的
属性。你现在拥有的这个太大了。你的重要内容在那个区域的中间占据了很小的一部分。

您当前的
视图框是:

viewBox="0 0 1512 1063"
与背景图像的不透明部分相匹配的更好的视图框是:

viewBox="472 16 616 960"
正文{
填料:10vw 30vw;
}
svg{
边框:5px实心;
}

使用Fabric.js 1.6.7创建
Votre企业
地址
Votre电话

您需要调整查看框的
属性。你现在拥有的这个太大了。你的重要内容在那个区域的中间占据了很小的一部分。

您当前的
视图框是:

viewBox="0 0 1512 1063"
与背景图像的不透明部分相匹配的更好的视图框是:

viewBox="472 16 616 960"
正文{
填料:10vw 30vw;
}
svg{
边框:5px实心;
}

使用Fabric.js 1.6.7创建
Votre企业
地址
Votre电话

您需要在此处发布标记和代码,而不是任何第三方网站。您希望我们研究三个CodePen示例并找出SVG中的差异吗?我在stackoverflow片段中添加了代码,对此表示抱歉。唯一的区别是svg中的图像。我添加了一些解释以使其更易于理解。您需要在此处发布标记和代码,而不是任何第三方网站。您希望我们研究三个CodePen示例并找出SVG中的差异吗?我在stackoverflow片段中添加了代码,对此表示抱歉。唯一的区别是svg中的图像。我添加了一些解释以使其更易于理解。