Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unexpected result when using Imagemagick to combine two images

Posted on 2014-03-11
7
Medium Priority
?
378 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 54

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 498 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 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1002 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
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

 

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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 1002 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
This article shows how to convert a multi-page PDF file into multiple image files, with one image file created for each page of the PDF. It does this by utilizing an excellent, free software package called GraphicsMagick. The solution is amazingly s…
The goal of the tutorial is to teach the user how to make his/her own presets while editing so it is easier to edit there photos. Create a preset you like and copy that setting then save it in to your presets folder.
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…
Suggested Courses

596 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