Immagine con filigrana

: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 Mi Piace

Questa è la prima versione e mi aspetto funzionalità mancanti. Attendo con ansia qualsiasi feedback! :+1:

7 Mi Piace

Grazie per il componente. Questo componente elabora le immagini? Questo componente comprime le immagini a una dimensione migliore dell’originale.

5 Mi Piace

Il componente non esegue alcuna modifica o compressione oltre all’applicazione della filigrana.

Discourse pre-elabora già l’immagine (utilizzando la libreria squoosh) → viene applicata la filigrana → L’immagine viene caricata sul server. Questo è il suo funzionamento.

6 Mi Piace


La prima volta che apri un post e lo modifichi, non puoi applicare una filigrana, devi pubblicarlo e poi fare clic su “modifica post” e caricare un’immagine per applicare una filigrana.
Il tema utilizzato è FKB Pro - Social theme - #375 by MihirR

2 Mi Piace

Intendi che se apri/modifichi un post esistente per la prima volta e carichi un’immagine, non c’è una filigrana. È corretto? Puoi riprodurlo ogni volta? Vedi qualche errore nella console del browser?

Se ho capito bene, ti aspetti che un’immagine esistente caricata (prima di questa installazione TC) abbia una filigrana quando modifichi il post (o abbia un modo per applicare la filigrana manualmente). Non funziona in questo modo. Devi caricare l’immagine per applicare una filigrana.

Avere un pulsante per applicare la filigrana manualmente a un’immagine selezionata potrebbe essere una funzionalità. Ti andrebbe bene?

Sono le immagini caricate dopo aver creato un nuovo post che non hanno una filigrana. Sono le immagini caricate dopo essere entrati nel post dopo aver pubblicato e cliccato su modifica che hanno la filigrana.

Per il pulsante di pubblicazione uso Compose Center - #13

Puoi fare un breve video, per favore? Sarebbe utile vederlo e capire cosa sta succedendo.

1 Mi Piace

3 Mi Piace

Grazie per la pazienza! Ho trovato il problema. Dovrebbe essere risolto ora! :+1:

3 Mi Piace

Si verifica questo errore durante l’installazione di questo componente

Đã xảy ra lỗi: Errore durante la creazione dell'asset di caricamento: worker_photon_wasm. Nome file originale Mi dispiace, il file che stai cercando di caricare non è autorizzato (estensioni autorizzate: jpg, jpeg, png, woff, woff2, svg, eot, ttf, otf, gif, js, dwg).

1 Mi Piace

È strano. Qual è la tua versione di Discourse?
Puoi provare ad aggiungere l’estensione wasm negli elenchi consentiti, ma funziona bene nelle mie due installazioni locali e di produzione senza alcuna modifica. :thinking:

1 Mi Piace

Riceverò un tuo feedback, non so cosa stia succedendo, ma sembra che gli utenti cinesi non abbiano filigrane sulle loro immagini caricate.

Ma sto usando un account appena creato con quella modalità “no-trace” attivata e funziona, quindi non so qual è il problema.

A volte funziona, a volte no.

Le immagini da rimuovere sono .jpeg .png Ma proprio come l’immagine nel video copio l’immagine e la carico e viene filigranata, quindi non so qual è il problema.

Grazie per il feedback!

Per te, non importa come provi, funziona sempre, vero?

Puoi chiedere ad alcuni dei tuoi utenti di controllare la console del browser se succede e copiarti qualsiasi messaggio di errore che vedono? Inoltre, se stanno usando un dispositivo mobile (Android, iPhone, ecc.) - Se possono spiegare cosa hanno fatto esattamente per vedere se può aiutare, sarebbe gradito.

Non sembra un problema con l’immagine stessa se in seguito puoi aggiungere la filigrana all’immagine. Ciò che rimane è o un errore nel codice come il problema precedente, o un errore nel processo di filigranatura. Sfortunatamente, non riesco a riprodurlo, non importa cosa faccio.

Mi assicurerò di aggiornare il componente in seguito per garantire che eventuali errori vengano rilevati e visualizzati all’utente.

Ciao, grazie per aver realizzato questo componente.
Quando ho provato a caricare la foto della filigrana, si è verificato questo errore. Ho provato anche JPEG e Webp, ma senza successo.

Il mio forum Discourse è aggiornato

1 Mi Piace

Ciao @LaptechInfo

È strano. A questo punto, il TC non dovrebbe fare nulla. Questa è l’impostazione di caricamento standard.
Puoi controllare la console del browser e vedere se ci sono messaggi di errore?

È possibile fornire un’immagine che non funziona in modo che possa testarla anche io?

1 Mi Piace

Ciao, ho provato molte immagini a caso, ma nessuna ha funzionato.
Non sono un programmatore, non ho conoscenze di alcun linguaggio informatico.
Prova questa immagine, ci ho provato.
laptechinfo webp.zip (558 Bytes)
watermark.zip (257.7 KB)

@Arkshine

1 Mi Piace

Grazie! Puoi anche mostrarmi il contenuto della tua Console? La scheda subito dopo. Penso che potrebbe aiutare.

EDIT: Penso di poterlo riprodurre, fammi vedere e ti farò sapere presto!

Scheda Console


@Arkshine

@LaptechInfo Grazie! C’è un bug in Discourse da un PR di ieri. Ho creato un argomento: Can't upload image in settings. :+1:

3 Mi Piace