ウォーターマーク画像

:information_source: Summary Automatically adds watermarks to user-uploaded images
:hammer_and_wrench: Repository GitHub - Arkshine/discourse-watermark-image
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Description

This theme component automatically adds watermarks to user-uploaded images. You can use either an image or a QR code as your watermark, with extensive customization options for position, appearance, and distribution patterns.

The component offers granular control through category and user group settings, allowing you to tailor the watermarking behavior to your community’s needs.

Please review the Important Notes section before implementation.

Features

  • High-performance processing using WebAssembly and Web Workers
  • Comprehensive image format support (PNG, JPEG, BMP, ICO, TIFF, WEBP)
  • Dynamic QR code watermark generation
  • Flexible sizing options (relative or absolute)
  • Versatile positioning system
  • Advanced appearance customization (opacity, rotation, scale, margin, etc.)
  • Multiple blending modes
  • Pattern distribution options (single, grid, diagonal, random)
  • Category and user group-specific settings
  • Live preview in settings panel

Settings

Setting Description
image The image to use as watermark.
Supported formats: PNG, JPEG, BMP, ICO, TIFF, WEBP.
Default: ""
size_mode How the watermark size is calculated:
- relative: Size is relative to the target’s image width.
- absolute: Applied at its original size.
Default: "relative"
relative_width The width of the watermark relative to the target image width (in %).
Only applies when the watermark size mode is set to relative.
Range: 1-100
Default: 10
absolute_scale Scale factor for original watermark size (only used in absolute mode). Min: 0.01
Default: 1
max_size Maximum size as percentage of image dimensions. Range: 1-100
Default: 50
position Position of the watermark: top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, bottom-right
Default: "bottom-right"
margin_x Horizontal margin from the edge (in % of the target image)
Default: 0
margin_y Vertical margin from the edge (in % of the target image)
Default: 0
opacity Watermark opacity. Range: 1-100
Default: 100
rotate Rotation angle.
Range: -360 to 360 degrees
Default: 0
blend_mode How the watermark blends with the image: normal, overlay, over, atop, xor, plus, multiply, burn, difference, soft_light, screen, hard_light, dodge, exclusion, lighten, darken.
Default: "normal"
pattern Watermark repetition pattern: single, grid, diagonal, random
Default: "single"
pattern_allow_partial Allow partial watermarks at image edges
Default: true
pattern_max_count Maximum number of watermark repetitions (0 for infinite)
Default: 50
pattern_spacing Spacing between repeated watermarks (in % of the target image)
Default: 15
qrcode_enabled Enable QR code watermark
Default: false
qrcode_text Text to encode in QR code. Supports placeholders: {homepage}, {username}, {topic_url}
Default: ""
qrcode_color QR code color (hex or CSS variable)
Default: "var(--primary)"
qrcode_background_color QR code background color (hex or CSS variable)
Default: "var(--secondary)"
qrcode_quiet_zone Width of white space border around QR code (0-10 modules)
Default: 2
qrcode_error_correction Error correction level: Low (~7%), Medium (~15%), Quarter (~25%), High (~30%)
More information about error correction levels can be found here.
Default: "Medium"
categories Categories where watermark should be applied.
Default: ""
groups Groups the watermark should be applied to.
Default: "0"
skip_small_images Skip watermarking if image is below min_image_dimensions.
Default: false
min_image_dimensions Minimum dimensions required (width x height)
Default: "200x200"
allow_non_supported_uploads Allow image uploads to continue even when format is not supported
Default: false

Watermark Types

Image

The component supports multiple image formats: PNG, JPEG, BMP, ICO, TIFF, and WEBP.
See the FAQ section for important information about format support limitations.

QR Code

Generate dynamic QR codes with customizable content using these variables:

  • {homepage} - The URL of the homepage
  • {username} - The username of the user
  • {topic_url} - The URL of the topic

Important: When styling QR code watermarks, consider contrast and sizing. Poor contrast ratios or excessive styling can make QR codes unreadable. Always test your QR code watermarks with scanning apps.

Real-Time Preview

The settings panel includes a real-time preview feature, allowing you to see how your watermark configuration affects a sample image instantly.
The preview window offers several interactive features:

  • Resizable and movable preview window
  • Option to load a random sample image
  • Support for uploading your own test images from your device

On the desktop, it opens automatically. You can also open from the button at the bottom of the page:

More images



:warning: Important Notes

  • Original Images Are Not Preserved
    Watermarks are applied before server upload, and original images are not retained. Thoroughly test your watermark settings before deploying to production.

  • If testing in the admin panel, be careful not to validate your settings immediately. I would recommend creating a group or a category to be safe.

FAQ

Why are image formats limited?

While Discourse converts all uploads to JPEG, this TC watermarking occurs pre-upload on the original format, using specific image processing libraries. While post-upload watermarking is possible, it would require multiple upload/download cycles and affect the composer experience. I’m still exploring improvements to this workflow.

Why isn’t text watermarking supported?

Text watermarking would require extensive configuration options (font selection, styling, etc.) that would be difficult to implement effectively without a dedicated interface. Image watermarks provide more flexibility and can be created using existing design tools.

Roadmap

Future development plans may include:

  • Multiple watermark profiles [1]
  • Original image preservation [2]
  • Post-upload watermarking

Credits

This theme component is powered by:


  1. The upload input is partially supported with the Object settings type – it can’t be done in a TC at the moment. ↩︎

  2. May require plugin development. ↩︎

「いいね!」 24

これは最初のバージョンであり、機能が不足している可能性があります。フィードバックをお待ちしています! :+1:

「いいね!」 7

コンポーネントありがとうございます。このコンポーネントは画像を処理しますか?このコンポーネントは元のサイズよりも優れたサイズに画像を圧縮しますか?

「いいね!」 5

コンポーネントは、透かしを適用する以外に変更や圧縮を行いません。

Discourse は、まず画像を前処理します(squoosh ライブラリを使用)-> 透かしが適用されます → 画像がサーバーにアップロードされます。これが仕組みです。

「いいね!」 6


最初に投稿を開いて編集するときは、透かしを入れることはできません。一度投稿してから「投稿の編集」をクリックし、画像をアップロードして透かしを入れる必要があります。
使用されているテーマは FKB Pro - Social theme - #375 by MihirR です。

「いいね!」 2

既存の投稿を初めて開く/編集して画像をアップロードした場合、ウォーターマークは表示されないということですか?これで合っていますか?毎回再現できますか?ブラウザのコンソールにエラーは表示されますか?

もし私の理解が正しければ、既存のアップロード済み画像(このTCインストール前)を編集時にウォーターマーク付きで表示するか、手動でウォーターマークを付ける方法を期待しているということですね。しかし、そのようには機能しません。ウォーターマークを適用するには画像をアップロードする必要があります。

選択した画像に手動でウォーターマークを付けるボタンがあれば、機能として追加できるかもしれません。それでよろしいでしょうか?

新しい投稿を作成した後にアップロードされた画像にはウォーターマークがありません。投稿後に投稿に入り、編集をクリックしてアップロードされた画像にはウォーターマークが付いています。

投稿ボタンについては、Compose Center - #13 を使用しています。

簡単なビデオを作成していただけますか?それを見ると理解しやすくなります。

「いいね!」 1

「いいね!」 3

お待ちいただきありがとうございます!問題を見つけました。これで修正されたはずです!:+1:

「いいね!」 3

このコンポーネントをインストールすると、このエラーが発生します。

Đã xảy ra lỗi: Error creating upload asset: worker_photon_wasm. Original filename 申し訳ありませんが、アップロードしようとしているファイルは承認されていません(承認された拡張子:jpg、jpeg、png、woff、woff2、svg、eot、ttf、otf、gif、js、dwg)。

「いいね!」 1

それは奇妙ですね。Discourseのバージョンは何ですか?

wasm拡張機能を許可リストに追加してみてください。私のローカル環境と2つの本番環境では、何も変更せずに正常に動作しています。:thinking:

「いいね!」 1

フィードバックをさせていただきます。何が起こっているのか分かりませんが、中国のユーザーはアップロードした画像にウォーターマークが付いていないようです。

しかし、私は新しく作成したアカウントで、そのノー・トレース・モードをオンにして使用していますが、機能しています。そのため、問題が何なのか分かりません。

時々機能したり、機能しなかったりします。

削除された画像は.jpeg .pngですが、ビデオ内の画像のようにコピーしてアップロードするとウォーターマークが付くので、問題が何なのか分かりません。

フィードバックありがとうございます!

あなたにとっては、どんなに試しても、いつもうまくいくのですね?

もしそれが起こった場合、ユーザーにブラウザのコンソールを確認してもらい、表示されるエラーメッセージをコピーして送ってもらうようお願いできますか?また、モバイルデバイス(Android、iPhoneなど)を使用しているかどうか、そしてもし可能であれば、何をしたのかを具体的に説明してもらうと、役立つかもしれません。

後でご自身で画像をウォーターマークできるのであれば、画像自体の問題ではないようです。残るは、以前の問題のようなコードのエラーか、ウォーターマーク処理のエラーかのどちらかです。残念ながら、私にはどんなにやっても再現できません。

後でコンポーネントを更新し、エラーが発生した場合にユーザーに表示されるようにします。

このコンポーネントを作成していただきありがとうございます。

透かし写真をアップロードしようとすると、このエラーが発生します。JPEG、Webpも試しましたが、うまくいきませんでした。

私のDiscourseフォーラムは最新の状態です

「いいね!」 1

@LaptechInfo様

それは奇妙ですね。この時点では、TCは何もすべきではありません。これは標準のアップロード設定です。
ブラウザのコンソールを確認して、エラーメッセージが表示されていないか確認していただけますか?

テストできるように、失敗した画像の提供は可能でしょうか?

「いいね!」 1

こんにちは。画像をランダムにいくつか試しましたが、どれも機能しませんでした。
私はプログラマーではなく、コンピューター言語の知識はありません。
この画像をお試しください。もう疲れました。
laptechinfo webp.zip (558 Bytes)
watermark.zip (257.7 KB)

@Arkshine

「いいね!」 1

ありがとうございます!コンソール(そのすぐ右隣のタブ)の内容も表示してもらえますか?それが役立つかもしれません。

編集:再現できると思います。確認して、すぐに連絡します!

コンソールタブ


@Arkshine

@LaptechInfo ありがとう!昨日のPRでDiscourseにバグがありました。トピックを作成しました: https://meta.discourse.org/t/cant-upload-image-in-settings/352213。 :+1:

「いいね!」 3