Skip to content

Commit

Permalink
fix(src): fix image page after crop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoukk committed May 25, 2019
1 parent 2bbfa85 commit 664a3ba
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,35 @@ func (image *KimgImagick) crop(mw *imagick.MagickWand, req *KimgRequest) error {

switch req.Offset {
case "lt":
x -= req.OffsetX
y -= req.OffsetY
{
x -= req.OffsetX
y -= req.OffsetY
}
case "lb":
x -= req.OffsetX
y += req.OffsetY
{
x -= req.OffsetX
y += req.OffsetY
}
case "rt":
x += req.OffsetX
y -= req.OffsetY
{
x += req.OffsetX
y -= req.OffsetY
}
case "rb":
x += req.OffsetX
y += req.OffsetY
{
x += req.OffsetX
y += req.OffsetY
}
}

if err := mw.CropImage(uint(req.CropW), uint(req.CropH), x, y); err != nil {
image.ctx.Logger.Warn("CropImage %d %d %d %d, err: %s", req.CropW, req.CropH, x, y, err)
return err
}
if err := mw.SetImagePage(uint(req.CropW), uint(req.CropH), 0, 0); err != nil {
image.ctx.Logger.Warn("SetImagePage %d %d %d %d, err: %s", req.CropW, req.CropH, 0, 0, err)
return err
}
image.ctx.Logger.Debug("CropImage %d %d %d %d", req.CropW, req.CropH, x, y)
return nil
}
Expand Down

0 comments on commit 664a3ba

Please sign in to comment.