Solved

Unexpected result when using Imagemagick to combine two images

Posted on 2014-03-11
7
367 Views
Last Modified: 2014-07-16
Hello All,

I am using ImageMagick-6.8.8-Q16 on a Windows 8 PC. I'm trying to use it to overlay one image, "overlay.jpg", on top of a "background.jpg". Both JPGs are the same size. I tried the following 3 commands, with these results:

convert background.jpg overlay.jpg -compose darken    -composite bg-ov-darken.jpg
convert background.jpg overlay.jpg -compose multiply  -composite bg-ov-multiply.jpg
convert background.jpg overlay.jpg -compose add       -composite bg-ov-add.jpg

Open in new window


resulting images
The first two options, "darken" and "multiply", give me the expected result. However, "add" gives me a bright blue in just one section of the image's overlap (the outputs are, top-bot, "darken", "multiply", and "add").

This is not what I was expecting... is it right? Or is this a bug? I have attached the two input JPGs.
background.jpg
overlay.jpg
0
Comment
Question by:futuremoose
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39922445
Please recreate what you want in photoshop or http://pixlr.com/ and lets focus on getting your desired output.    

What you are seeing in blue is not a bug though.
0
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 166 total points
ID: 39922704
I tried to see the math behind "add", but can't find it on the guide: http://www.imagemagick.org/Usage/compose/

The mathematical compose operators are: Multiply,  Screen,  Bumpmap,  Divide,  Plus,  Minus,  ModulusAdd,  ModulusSubtract,  Difference,  Exclusion,  Lighten,  Darken,  LightenIntensity,  DarkenIntensity

Dan
0
 
LVL 53

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 334 total points
ID: 39923327
It's explained more here http://www.imagemagick.org/Usage/compose/
rgbhttp://www.imagemagick.org/script/compose.php

plus      The source is added to the destination and replaces the destination. This operator is useful for averaging or a controled merger of two images, rather than a direct overlay.

add      As per 'plus' but transparency data is treated as matte values. As such any transparent areas in either image remain transparent.

Again, let's concentrate on what your expected output needs to be or are you just playing?
0
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 

Author Comment

by:futuremoose
ID: 39925224
Hi Guys,

First, thanks for helping... sorry for kind of late reply, but I am probably in a very different time zone (Tokyo).

As Scott pointed out, both "Plus" and "Add" are on the URL he mentione, but "Add" is not for some reason.

Anyhow "Plus" gives me an all white result (which I think is what I would expect from the description) but "Add" is supposed to be same as "Plus" but treats transparency differently... neither of which explains the blue result (at least to me... can you tell me how the blue overlap is possible? I must be missing something).

Anyhow, I'm not just playing... I need to merge two images and have the overlap color match the customers RGB spec exactly. This should explain exactly what I am trying to do. I hope you can help... thanks in advance.

an illustration
0
 

Author Comment

by:futuremoose
ID: 39925263
As you can see in the above post, neither the add or multiply gives me quite the result I need. Perhaps I need to use a "blend" of some sort?
0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 334 total points
ID: 39925413
Where are you getting your color values from because they don't seem to match up in photoshop.  That could be a function of screen calibration on my end.  

"multiply" gives you a much different result that your first posted compared to  http:#a39925224.  

I use image magick on my server but I use it for uploading images to a webserver, resizing, making thumbnails.  I have only dabbled in blending and never did anything exact because of course with all different monitors calibrations, it is futile to get an exact color.  

If you need to use pure rgb numbers and not worry about how they appear on any given screen, then we we probably need to enlist the help of somebody more versed in the physics of color.
0
 

Author Closing Comment

by:futuremoose
ID: 40201196
Never really got a good answer on why I was getting the unexpected blue result. Anyhow, I found another way around the problem. Thanks everyone for their help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As each individual will have his or her personal way of processing a concept and turning it into a reality, this is simply a record of my own system as a designer. It may feel daunting or even overwhelming when developing a new idea for a project…
PaperPort 14.5 Patch 1 update is often not detected or downloaded automatically. This article provides direct download links to solve the problem for retail (non-bundled) versions of the Standard and Professional editions, as well as the Professiona…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question