DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Making Dropwizard Metrics Accessible via CQL in Apache Cassandra
  • Source-Driven Development in Salesforce: Managing Metadata and API Versions
  • How to Introduce a New API Quickly Using Micronaut
  • Building a Real-Time Audio Transcription System With OpenAI’s Realtime API

Trending

  • ITBench, Part 1: Next-Gen Benchmarking for IT Automation Evaluation
  • Navigating and Modernizing Legacy Codebases: A Developer's Guide to AI-Assisted Code Understanding
  • The Role of AI in Identity and Access Management for Organizations
  • Agile’s Quarter-Century Crisis
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Dynamic Watermarking With IMGProxy and Apache APISIX

Dynamic Watermarking With IMGProxy and Apache APISIX

In this post, we implement a watermarking feature with the help of imgproxy. The more I think about it, the more I think they make a match made in Heaven.

By 
Nicolas Fränkel user avatar
Nicolas Fränkel
DZone Core CORE ·
Jul. 17, 24 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
5.5K Views

Join the DZone community and get the full member experience.

Join For Free

Last week, I described how to add a dynamic watermark to your images on the JVM. I didn't find any library, so I had to develop the feature, or, more precisely, an embryo of a feature, by myself. Depending on your tech stack, you must search for an existing library or roll up your sleeves. For example, Rust offers such an out-of-the-box library. Worse, this approach might be impossible to implement if you don't have access to the source image.

Another alternative is to use ready-made components, namely imgproxy and Apache APISIX. I already combined them to resize images on-the-fly.

Here's the general sequence flow of the process:

watermark

  • When APISIX receives a specific pattern, it calls imgproxy with the relevant parameters
  • imgproxy fetches the original image and the watermark to apply
  • It watermarks the original image and returns the result to APISIX

Let's say the pattern is /watermark/*.

We can define two routes:

YAML
 
routes:
  - uri: "*"                                                                     #1
    upstream:
      nodes:
        "server:3000": 1
  - uri: /watermark/*                                                            #2
    plugins:
      proxy-rewrite:                                                             #3
        regex_uri:
          - /watermark/(.*)
          - /dummy_sig/watermark:0.8:nowe:20:20:0.2/plain/http://server:3000/$1  #4
    upstream:
      nodes:
        "imgproxy:8080": 1                                                       #5


  1. Catch-all route that forwards to the web server
  2. Watermark images route
  3. Rewrite the URL...
  4. ...with an imgproxy-configured route and...
  5. ...forward to imageproxy

You can find the exact rewritten URL syntax in imgproxy documentation. The watermark itself is configured via a single environment variable. You should buy imgproxy's Pro version if you need different watermarks. As a poor man's alternative, you could also set up different instances, each with its watermark, and configure APISIX to route the request to the desired instance.

In this post, we implemented a watermarking feature with the help of imgproxy. The more I think about it, the more I think they make a match made in Heaven.

The complete source code for this post can be found on GitHub.

To Go Further

  • Digital watermarking
  • imgproxy documentation
  • imgproxy interactive demo
Java virtual machine API

Published at DZone with permission of Nicolas Fränkel, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Making Dropwizard Metrics Accessible via CQL in Apache Cassandra
  • Source-Driven Development in Salesforce: Managing Metadata and API Versions
  • How to Introduce a New API Quickly Using Micronaut
  • Building a Real-Time Audio Transcription System With OpenAI’s Realtime API

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!