Skip to content

Commit 733260f

Browse files
committed
remove trailing blanks from watermark
1 parent 92de3d0 commit 733260f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

example/watermark.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/luajit
1+
#!/usr/bin/luajit
22

33
-- add a simple text watermark to an image
44
-- ./watermark.lua ~/pics/IMG_0073.JPG x.jpg "Hello <i>world!</i>"
@@ -11,22 +11,21 @@ local vips = require "vips"
1111
local im = vips.Image.new_from_file(arg[1], {access = "sequential"})
1212

1313
-- make the text mask
14-
local text =
15-
vips.Image.text(arg[3], {width = 200, dpi = 200,
16-
align = "centre", font = "sans bold"})
14+
local text = vips.Image.text(arg[3],
15+
{width = 200, dpi = 200, align = "centre", font = "sans bold"})
1716
text = text:rotate(-45)
1817
-- make the text transparent
1918
text = (text * 0.3):cast("uchar")
2019
text = text:gravity("centre", 200, 200)
2120
-- this block of pixels will be reused many times ... make a copy
22-
--text = text:copy_memory()
23-
text = text:replicate(1 + im:width() / text:width(),
21+
text = text:copy_memory()
22+
text = text:replicate(1 + im:width() / text:width(),
2423
1 + im:height() / text:height())
2524
text = text:crop(0, 0, im:width(), im:height())
2625

2726
-- we make a constant colour image and attach the text mask as the alpha
28-
local overlay =
29-
text:new_from_image({255, 128, 128}):copy({interpretation = "srgb"})
27+
local overlay =
28+
text:new_from_image({255, 128, 128}):copy{interpretation = "srgb"}
3029
overlay = overlay:bandjoin(text)
3130

3231
-- overlay the text

0 commit comments

Comments
 (0)