Solved

Unexpected result when using Imagemagick to combine two images

Posted on 2014-03-11
7
356 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
  • 3
  • 3
7 Comments
 
LVL 52

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 34

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 52

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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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 52

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What happens to your iCloud storage? 6 187
Optimize Images 4 83
Simple 3D CAD 18 113
Employee Badges -- COLOR printer & software ? 2 151
This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
The goal of the tutorial is to teach the user how to use the cropping tool and to straighten there photos so it does not look tilted. You will choose which photo you want to edit, crop it to you liking and make it straight.
The goal of the tutorial is to teach the user how to edit a basic portrait of someone. This tutorial shows how to edit two basic photographs, one of a car and one of a person.

838 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