Colouring multiple images then layering with varying opacity

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
johnbanshee
Posts: 1
Joined: 2013-01-08T04:39:53-07:00
Authentication code: 6789

Colouring multiple images then layering with varying opacity

Post by johnbanshee »

Hi,

Only just started using imagaemajick so a newbie I'm afraid.

I'm trying to accomplish the following:

Choose a small selection of images [will be three in the following example]

Background - dots.png
Overlay circle.png - colorize red and make opacity 50%
Flatten image and save as PNG [rendered.png]

So here's my code in PHP:

<?php
$tempfile1 = ROOT . '/PUBLIC/_images/flexlayers/dots.png';
$tempfile2 = ROOT . '/PUBLIC/_images/flexlayers/star.png';
$output = ROOT . '/PUBLIC/_images/flexlayers/rendered.png';

exec('convert.exe "'.$tempfile1.'" +level-colors #FF0000, ("'.$tempfile2 .'" +level-colors #0000FF, -alpha on -channel a -evaluate set 25%) -composite "'.$output.'"');

?>

I'm halfway there but the following is happening in rendered.png

Image

* dots.png is being coloured red
* star.png is being coloured blue BUT dots.png is also being coloured blue resulting in purple
* the 25% opcaity is being applied to both layers, not just star.png

Can anyone adivse on how I make the operations apply only to a specific layer - do I need to perform multiple saves and reload each time?

Kind Regards

JB
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Colouring multiple images then layering with varying opa

Post by snibgo »

You haven't provided the actual sources, so I can't test any code.

I suggest you break down your operations into individual commands and run them from the command line, and see if you get the results you expect. When it works, combine them into a single command.

For example:

Code: Select all

convert start.png +level-colors -alpha on -channel a -evaluate set 25% x.png
will set all the pixels to 25% transparency. I am unclear if this is what you want.

I think it's best to provide the second argument to "-level-colors".
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Colouring multiple images then layering with varying opa

Post by fmw42 »

parenthesis must have a space to separate it from what is inside it. You can also add -respect-parenthesis right after convert, to try to ensure each parenthesis commands are processed separately and do not take on previous settings.
Post Reply