如何在Grails中使用刻录图像插件时居中对齐水印

时间:2015-04-09 11:15:14

标签: grails

我需要对上传的图片应用水印。根据刻录图像的文档,这可以通过以下代码完成:

def orginalFileName      
burningImageService.doWith('path/to/my/file.jpg', 'path/to/output/dir')
    .execute {
        it.scaleApproximate(800, 600)
        orginalFileName = it.watermark('path/to/watermark',
                                       ['right':10, 'bottom': 10])
    }
    .execute ('thumbnail', {
        it.scaleAccurate(200, 200)
    })

是否有一种简单的方法可以使水印居中对齐而无需计算坐标?我不能使用给定的尺寸(800,600),因为它是一个近似的尺寸。我无法使用scaleAccurate,因为我不想裁剪图像。

1 个答案:

答案 0 :(得分:3)

只需从参数中移除位置坐标,默认情况下它将使水印居中。

burningImageService.doWith('path/to/my/file', 'path/to/output/dir')
                   .execute {
                       it.watermark('path/to/watermark')
                    }

欲了解更多信息,请参阅: https://code.google.com/p/burningimage/wiki/Images_manipulation_handling

相关问题