Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
10BC0 feat(gotify): Add public URL support and configurable image quality by InterN0te · Pull Request #1126 · roflcoopter/viseron · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

InterN0te
Copy link
Contributor
@InterN0te InterN0te commented Oct 13, 2025

Summary

Depends on: #1125

This adds support for using the webserver's public image URL system in Gotify notifications, allowing images to be viewed from external networks without authentication. Also improves image quality configuration for high-resolution cameras.

Features

Public URL Support

  • ✅ New option: use_public_url (default: false) to use public URLs instead of base64
  • ✅ Images are now persistent and accessible after Viseron restart
  • ✅ Images can be viewed from external networks (not just localhost)
  • ✅ Retrieves public_base_url and public_url_expiry_hours from webserver config

Image Quality Improvements

  • ✅ Configurable JPEG quality: image_quality (1-100, default: 95)
  • ✅ Configurable max size: image_max_size (0-7680, default: 800)
    • Set to 0 to disable resizing (use original camera resolution)
    • Recommended: 1920 for 4K cameras
  • ✅ Applies to both base64 and public URL images

Configuration Changes

  • ✅ Moved public_base_url from Gotify to webserver (global setting)
  • ✅ Moved public_url_expiry_hours from Gotify to webserver (global setting)
  • ✅ These settings are now reusable by other notification components

Configuration

Before (old way - base64 only)

gotify:
  gotify_url: "https://gotify.example.com"
  gotify_token: "your-token"
  send_thumbnail: true
  cameras:
    camera_4k:
      send_thumbnail: true

Result: 800x450px image, ~87KB, base64 encoded

After (new way - public URLs with high quality)

webserver:
  public_base_url: "https://viseron.example.com"
  public_url_expiry_hours: 168  # 7 days

gotify:
  gotify_url: "https://gotify.example.com"
  gotify_token: "your-token"
  use_public_url: true          # Use public URLs
  image_max_size: 1920          # Full HD for 4K cameras
  image_quality: 95             # High quality
  send_thumbnail: true
  cameras:
    camera_4k:
      use_public_url: true      # Can override per camera

Result: 1920x1080px image, high quality, accessible after restart

Fixes

  • ✅ Images from 4K cameras are no longer limited to 800x450px
  • ✅ Public URLs survive container restarts (images stored in /config/public_images/)
  • ✅ Better image quality control for all notification types
  • ✅ Images accessible from external networks (useful for mobile Gotify clients)

Breaking Changes

None - all new options have sensible defaults. Existing configurations continue to work unchanged.

Testing

  1. Configure webserver with public_base_url
  2. Enable use_public_url: true in Gotify
  3. Trigger a detection
  4. Verify image appears in Gotify notification
  5. Restart Viseron
  6. Click on image in old notification - should still work
  7. After expiry time, image should be cleaned up

This introduces a reusable system for serving images publicly without authentication, useful for external notification services like Gotify, Discord, or Telegram.

Features:
- Token-based public image access via /api/v1/publicimage endpoint
- No authentication required for accessing images with valid tokens
- Configurable expiration time (default: 24 hours, max: 31 days)
- Persistent storage in /config/public_images/ (survives restarts)
- Automatic cleanup of expired images (periodic + on startup)
- Validates file existence even if token not in memory (handles restarts)

Configuration options:
- public_base_url: External URL for Viseron (e.g., https://viseron.example.com)
- public_url_expiry_hours: How long public URLs remain valid (default: 24)

Technical details:
- Images stored with UUID token as filename
- Tokens stored in memory with expiration timestamp
- After restart, API falls back to disk lookup if token not in memory
- Hourly cleanup task removes expired tokens and files
- Startup cleanup removes orphaned files older than max expiry
- Supports JPG and PNG formats

Example usage:
```yaml
webserver:
  public_base_url: "https://viseron.example.com"
  public_url_expiry_hours: 48
```
This adds support for using the webserver's public image URL system in Gotify notifications, allowing images to be viewed from external networks without authentication. Also improves image quality configuration for high-resolution cameras.

Depends on: Public image URL system (#PR1_NUMBER)

Features:
- New option: use_public_url (default: false) to use public URLs instead of base64
- Images are now persistent and accessible after Viseron restart
- Configurable image quality (image_quality: 1-100, default: 95)
- Configurable image size (image_max_size: 0-7680, default: 800)
  - Set to 0 to disable resizing (use original camera resolution)
  - Recommended: 1920 for 4K cameras, 0 for maximum quality
- Images saved to persistent directory instead of /tmp/
- Retrieves public_base_url and public_url_expiry_hours from webserver config

Configuration changes:
- Moved public_base_url to webserver config (was in Gotify)
- Moved public_url_expiry_hours to webserver config (was in Gotify)
- These are now global settings usable by all notification components

Image quality improvements:
- Base64 images now use configured JPEG quality
- Public URL images use configured quality and size
- Fixes low quality issue with 4K cameras (was hardcoded to 800px)

Example configuration:
```yaml
webserver:
  public_base_url: "https://viseron.example.com"
  public_url_expiry_hours: 168  # 7 days

gotify:
  gotify_url: "https://gotify.example.com"
  gotify_token: "your-token"
  use_public_url: true
  image_max_size: 1920  # For 4K cameras
  image_quality: 95     # High quality JPEG
  cameras:
    camera_name: {}
```

Fixes:
- Images from 4K cameras are no longer limited to 800x450px
- Public URLs survive container restarts
- Better image quality control for all notification types
Copy link
netlify bot commented Oct 13, 2025

Deploy Preview for viseron ready!

Name Link
🔨 Latest commit b492f28
🔍 Latest deploy log https://app.netlify.com/projects/viseron/deploys/68f421a2bb260d0008f0a049
😎 Deploy Preview https://deploy-preview-1126--viseron.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

- Remove unused datetime import in publicimage.py
- Fix type annotation for _cleanup_task (asyncio.Task | None)
- Simplify cleanup task cancellation to avoid unreachable code
- Break long log messages to stay within 88 character limit
- Use %s formatting instead of f-strings for long messages
- Shorten comments while preserving meaning
- Move WEBSERVER_COMPONENT import to module level
- Break long DESC_IMAGE_QUALITY string across lines
- Remove useless broad-except suppression comment
@roflcoopter
Copy link
Owner

Thank you and great job on this!
The docs needs to be regenerated for webserver and gotify since you introduced new keys: https://viseron.netlify.app/docs/developers/documentation#component-documentation

Otherwise i think everything looks good.

Thibaut and others added 5 commits October 17, 2025 15:13
Add documentation for the new public_base_url and public_url_expiry_hours configuration options that enable public image URL generation with token-based access.
Add documentation for new Gotify features:
- use_public_url option to generate temporary public URLs for images
- image_max_size to control thumbnail dimensions (default 800px)
- image_quality to control JPEG quality (default 95)

These options allow better control over image delivery and file sizes.
@InterN0te
Copy link
Contributor Author

Thank you and great job on this! The docs needs to be regenerated for webserver and gotify since you introduced new keys: https://viseron.netlify.app/docs/developers/documentation#component-documentation

Otherwise i think everything looks good.

Yes, you're right, I forgot about the documentation. I just updated them, it should be good now.

Thibaut added 5 commits October 18, 2025 01:15
The cleanup of expired public images was incorrectly using utcnow()
which could cause premature deletion when the system timezone differs
from UTC. Changed to use current system time for file mtime comparisons.

Also simplified the cleanup logic to be file-based rather than
token-based, making it more robust across restarts.
Add configurable download limit for public image tokens to automatically
delete images after a specified number of downloads.

Changes:
- Add remaining_downloads field to PublicImageToken dataclass
- Implement download counter decrement in publicimage API
- Add automatic cleanup after final download
- Add public_url_max_downloads configuration parameter (default: 0 = unlimited)
- Update webserver documentation with usage examples

Configuration:
- 0 (default): Unlimited downloads
- 1: Single-use URL (perfect for notifications)
- N > 1: Limited sharing (delete after N downloads)
…blic-url-support

Add download limit feature for public image URLs.
Update Gotify component to use the new public_url_max_downloads
configuration parameter when creating public image tokens.

Changes:
- Get max_downloads from webserver configuration
- Pass max_downloads as remaining_downloads to PublicImageToken
- Default behavior: 0 = unlimited downloads (only time expiration applies)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0