fix(图片裁剪): 修正图片重复裁剪
build.yaml / build (push) Successful in 39s

This commit is contained in:
xiaoqidun committed 2026-09-26 11:30:17 +08:00
1 parent c3908819bb
commit d9046af3b0
2 files changed
+36 -1

No files matched your search

+9
View File
@@ -115,6 +115,15 @@ func imageBorderObject(object ImageObject, box Box) PathObject {
// 返回: error 裁剪转换错误
func (c *semanticCompiler) addImage(img image.Image, matrix Matrix, clip *GeometryPath) error {
command := RasterCommand{Image: img, Transform: RasterMatrix(matrix.Values())}
if clip != nil {
if box, ok := geometryRectangleBounds(*clip); ok {
bounds := img.Bounds()
visible := matrix.TransformBox(Box{X: float64(bounds.Min.X), Y: float64(bounds.Min.Y), W: float64(bounds.Dx()), H: float64(bounds.Dy())})
if box.X <= visible.X && box.Y <= visible.Y && visible.X+visible.W <= box.X+box.W && visible.Y+visible.H <= box.Y+box.H {
clip = nil
}
}
}
if clip != nil {
var err error
command.Clip, err = c.segments(*clip)