Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:24:10+00:00 2026-06-18T06:24:10+00:00

I’m working on a program to dynamically add watermarks to product images with Image::Magick

  • 0

I’m working on a program to dynamically add watermarks to product images with Image::Magick. I’m using composite with the dissolve method. The watermark image is a PNG that has transparency. It’s running on Linux with ImageMagick 6.7.6-9 2012-05-16 Q16.

Consider the following arbitrary example images:

Background (test.jpg):

Background (product image)

Watermark/overlay (example.png):

Example watermark

If I put these together with the command line tool composite, everything is great.

composite -dissolve 60% -gravity center example.png test.jpg out.jpg

Correct output of CLI

The text (this needs to be an image, there will be graphics in it, too) is superimposed over the background. The edges are just the way they were in the original watermark image.

#!/usr/bin/perl
use strict; use warnings;
use Image::Magick;

# this objects represents the background
my $background = Image::Magick->new;
$background ->ReadImage( 'test.jpg' );

# this objects represents the watermark
my $watermark = Image::Magick->new;
$watermark->ReadImage( 'example.png');

# there is some scaling going on here...
# both images are scaled down to have the same width
# but the problem occurs even if I turn the scaling off

# superimpose the watermark
$background->Composite(
  image    => $watermark,
  compose  => 'Dissolve',
  opacity  => '60%',
  gravity  => 'Center',
);

$background->Write( filename => 'out.jpg' );

Here’s the output of this Perl program:

Weird output of Perl program

As you can see, the new image has some strange edges, almost like an outline. The larger this image gets (the original source images are both > 1000px) the more obvious this outline becomes.

Here’s a closeup:

Closup of correct image

Closeup of incorrect image

I believe it might have something to do with the strength of the JPEG compression because the wrong image has a lot more artefacts. But that would mean the defaults of Perl’s Image::Magick and the CLI are different. I have not figured out how to set the compression yet.

Anyway, I’d be glad about any kind of input on why this might happen, or ideas and suggestions on how to get rid of it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:24:11+00:00Added an answer on June 18, 2026 at 6:24 am

    I had a quick look at the PerlMagick source code and it seems that Composite with Dissolve is buggy when the dissolved image has an alpha channel. The following works for me:

    $watermark->Evaluate(
      operator => 'Multiply',
      value    => 0.6,
      channel  => 'Alpha',
    );
    
    $background->Composite(
      image    => $watermark,
      gravity  => 'Center',
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JSon response to parse title,date content and thumbnail images and place
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.