(self, ctx: PipelineContext)
| 369 | |
| 370 | class WatermarkWithTimestampFilter(FilterProcessor): |
| 371 | def process(self, ctx: PipelineContext): |
| 372 | img = ctx.get_buffer()[0] |
| 373 | |
| 374 | if "height" not in ctx: |
| 375 | ctx.set("height", int(img.height * .02)) |
| 376 | # 使用注册表动态获取处理器,避免直接导入 |
| 377 | multi_text_processor = get_processor("multi_rich_text") |
| 378 | if multi_text_processor: |
| 379 | multi_text_processor().process(ctx) |
| 380 | else: |
| 381 | raise RuntimeError("multi_rich_text processor not found") |
| 382 | text = ctx.get_buffer()[0] |
| 383 | |
| 384 | text_x = int(img.width * .93) - text.width |
| 385 | text_y = int(img.height * .95) |
| 386 | |
| 387 | img.paste(text, (text_x, text_y), mask=text) |
| 388 | ctx.update_buffer([img]).save_buffer(self.name()).success() |
| 389 | |
| 390 | def name(self) -> str: |
| 391 | return "watermark_with_timestamp" |
nothing calls this directly
no test coverage detected