问题描述
我正在使用vips PHP库。我想在图像上添加svg路径。我为此实现了以下代码,但没有给我预期的输出。问题是如何根据实际图像的高度和宽度设置svg路径。我尝试使用调整大小和缩略图,但没有给我预期的输出。我也想在实际的图像块上填充灰色,就像预期的输出图像一样。
$background = Vips\Image::newFromFile($arg[1],['access' => 'sequential']);
$svg = Vips\Image::svgload_buffer('<svg>
<path
d="M0 200 v-200 h200
a100,100 90 0,1 0,200
a100,1 -200,0
z" stroke="#fff" fill="transparent"/>
</svg>');
// $svg = $svg->resize(2.5);
$svg = $svg->thumbnail_image(700,['height' => 700,'size' => 'both']);
$image = $background->composite($svg,'dest-in');
$image->writetoFile([$arg2],['background' => [128,128,128],'Q' => 100]);
以下是我添加了svg路径的图像
我的vips输出图像
预期的输出图像
解决方法
尝试:
subView.centerXAnchor.constraint(equalTo: parentView.centerXAnchor).isActive = true
subView.centerYAnchor.constraint(equalTo: parentView.centerYAnchor).isActive = true
相关的github问题:https://github.com/libvips/php-vips/issues/109