علامة مائية على الصورة

: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 Sorry, the file you are trying to upload is not authorized (authorized extensions: jpg, jpeg, png, woff, woff2, svg, eot, ttf, otf, gif, js, dwg).

إعجاب واحد (1)

هذا غريب. ما هو إصدار Discourse الخاص بك؟
يمكنك محاولة إضافة امتداد wasm إلى القوائم المسموح بها، ولكنه يعمل بشكل جيد في تثبيتي المحلي واثنين من تثبيتات الإنتاج دون أي تغييرات. :thinking:

إعجاب واحد (1)

سأقدم لك بعض الملاحظات، لا أعرف ما يجري، ولكن يبدو أن المستخدمين الصينيين ليس لديهم علامات مائية على صورهم التي تم تحميلها.

لكنني أستخدم حسابًا تم إنشاؤه حديثًا مع تشغيل وضع عدم التتبع هذا وهو يعمل، لذلك لا أعرف ما هي المشكلة.

أحيانًا يعمل، وأحيانًا لا.

الصور التي تم إنزالها هي .jpeg .png ولكن مثل الصورة الموجودة في الفيديو، أقوم بنسخ الصورة وتحميلها وتكون عليها علامة مائية، لذلك لا أعرف ما هي المشكلة.

شكرا على ملاحظاتك!

بالنسبة لك، بغض النظر عن كيفية محاولتك، فإن الأمر يعمل دائمًا، أليس كذلك؟

هل يمكنك أن تطلب من بعض المستخدمين لديك التحقق من وحدة تحكم المتصفح إذا حدث ذلك ونسخ أي رسالة خطأ يرونها إليك؟ أيضًا، سواء كانوا يستخدمون جهازًا محمولاً (أندرويد، آيفون، إلخ) - إذا كان بإمكانهم شرح ما فعلوه بالضبط لمعرفة ما إذا كان ذلك يمكن أن يساعد، فسيكون ذلك موضع ترحيب.

لا يبدو أنه مشكلة في الصورة نفسها إذا كان بإمكانك وضع علامة مائية على الصورة بنفسك لاحقًا. ما تبقى هو إما خطأ في الكود مثل المشكلة السابقة، أو خطأ في عملية وضع العلامات المائية. لسوء الحظ، لا يمكنني تكرار ذلك مهما فعلت.

سأعمل على تحديث المكون لاحقًا للتأكد من التقاط أي أخطاء وعرضها للمستخدم.

مرحباً، شكراً لك على إنشاء هذه المكونة.
عندما حاولت تحميل صورة العلامة المائية، ظهر هذا الخطأ، جربت JPEG و Webp أيضاً، ولكن لم أنجح.

منتدى Discourse الخاص بي محدث

إعجاب واحد (1)

مرحباً @LaptechInfo

هذا غريب. في هذه المرحلة، يجب ألا يقوم TC بأي شيء. هذا هو إعداد التحميل القياسي.
هل يمكنك النظر في وحدة تحكم المتصفح ومعرفة ما إذا كنت ترى أي رسائل خطأ؟

هل من الممكن تقديم صورة تفشل حتى أتمكن من الاختبار من جانبي أيضًا؟

إعجاب واحد (1)

مرحباً، لقد جربت العديد من الصور عشوائياً، لكن لم تعمل أي منها.
أنا لست مبرمجاً، وليس لدي أي معرفة بأي لغات حاسوبية.
جرب هذه الصورة، لقد تعبت.
laptechinfo webp.zip (558 Bytes)
watermark.zip (257.7 KB)

@Arkshine

إعجاب واحد (1)

شكرًا! هل يمكنك أيضًا عرض محتويات وحدة التحكم (Console) الخاصة بك؟ علامة التبويب التالية. أعتقد أنها قد تساعد.

تعديل: أعتقد أنني أستطيع تكرار ذلك، دعني أرى، وسأعود إليك قريبًا!

علامة تبويب وحدة التحكم


@Arkshine

@LaptechInfo شكرا! هناك خطأ في Discourse من طلب سحب (PR) بالأمس. لقد أنشأت موضوعًا: Can't upload image in settings. :+1:

3 إعجابات