asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
442 stars 107 forks source link

Could I configure the watermark of the image? #111

Open diguage opened 8 years ago

diguage commented 8 years ago

I want to add a watermark to the images.

I google it, then I found I can add watermark to the pdf document with pdf template. And I found @mojavelinux added a comment to twetter https://twitter.com/ysb33r/status/650976750327959552 : Don't do it. It's a floodmark, a tell-tell antipattern. There's your solution ;)

Could I configure the watermark of the image? Does Asciidoctor plan to support the feature?

mojavelinux commented 8 years ago

Did you mean to file this issue in asciidoctor-pdf? I'm not exactly clear where you want a watermark to be applied. Do you want it to be a background/foreground image on each PDF page or on the image generated by Asciidoctor Diagram?

Don't do it. It's a floodmark, a tell-tell antipattern. There's your solution ;)

That comment applies specifically to presentations.

diguage commented 8 years ago

I want to add watermark on the images what are gernerated by Asciidoctor Diagram and/or linked on document.

For example, my website is http://www.diguage.com/, I want to show the link on all the images in the document was generated by Asciidoctor.

mojavelinux commented 8 years ago

Asciidoctor Diagram primarily just invokes the different diagram generators. Therefore, the diagram generator itself would need to support this feature. If/when it does, then Asciidoctor Diagram could be sure to pass on the necessary information or configuration.

diguage commented 8 years ago

@mojavelinux OK, I see. Thanks.

Could Asciidoctor add watermark to the exist images what were referenced?

mojavelinux commented 8 years ago

The challenge is that adding a watermark is a very open-ended requirement. There are as many ways to add a watermark as their are designs in the world. We would either have to pick a style (placement, font family, font size, font color, etc) and use that, or we'd get into the realm of trying to design a configuration language for controlling it.

However, what we could do is provide an API hook / extension point for post-processing / filtering the generated image. That would give an Asciidoctor Diagram user an opportunity to decorate the generated image however you saw fit. You could use something like rmagick to add a watermark. I think this is the best approach. wdyt?

pepijnve commented 8 years ago

Using imagemagick to overlay text as a post processing step is how I would do it as well.

Not sure how to provide an extension point in the diagram generators though. That would require an additional extension registration system. Would a dummy post process method that you could monkey patch be sufficient or is something more structured needed?

mojavelinux commented 8 years ago

I would image that Asciidoctor Diagram itself would expose an API to register a post processor or callback. I haven't thought much deeper than that about it.