Working with alpha channel

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?".
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

Please tell me
how this image

Image

Code: Select all

convert -alpha off
Image

made like this

Image

Code: Select all

convert -alpha off
Image

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

Re: Working with alpha channel

Post by snibgo »

It can't. The process needs to know which pixels to smear, and which mustn't be smeared. One of your previous images contains this information: the black shadow beneath the bird against the white background, birdBkW.png.
snibgo's IM pages: im.snibgo.com
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

I think you can do so

Code: Select all

ImageMagick\convert ^
1.png ^
-alpha background ^
-alpha off ^
2.png

ImageMagick\convert ^
2.png ^
-transparent White ^
-compose DstOver ^
( -clone 0 ) -geometry +1+0 -composite ^
( -clone 0 ) -geometry +2+0 -composite ^
( -clone 0 ) -geometry +4+0 -composite ^
( -clone 0 ) -geometry +8+0 -composite ^
( -clone 0 ) -geometry +16+0 -composite ^
( -clone 0 ) -geometry +32+0 -composite ^
( -clone 0 ) -geometry +64+0 -composite ^
( -clone 0 ) -geometry +128+0 -composite ^
( -clone 0 ) -geometry -1+0 -composite ^
( -clone 0 ) -geometry -2+0 -composite ^
( -clone 0 ) -geometry -4+0 -composite ^
( -clone 0 ) -geometry -8+0 -composite ^
( -clone 0 ) -geometry -16+0 -composite ^
( -clone 0 ) -geometry -32+0 -composite ^
( -clone 0 ) -geometry -64+0 -composite ^
( -clone 0 ) -geometry -128+0 -composite ^
-background White -compose Over -layers flatten ^
2.png
continue to use your code

But I do not understand how do I set the alpha channel
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

I figured, thank you very much.

Code: Select all

ImageMagick\convert ^
1.png ^
-alpha background ^
-alpha off ^
-transparent White ^
-compose DstOver ^
( -clone 0 ) -geometry +1+0 -composite ^
( -clone 0 ) -geometry +2+0 -composite ^
( -clone 0 ) -geometry +4+0 -composite ^
( -clone 0 ) -geometry +8+0 -composite ^
( -clone 0 ) -geometry +16+0 -composite ^
( -clone 0 ) -geometry +32+0 -composite ^
( -clone 0 ) -geometry +64+0 -composite ^
( -clone 0 ) -geometry +128+0 -composite ^
( -clone 0 ) -geometry -1+0 -composite ^
( -clone 0 ) -geometry -2+0 -composite ^
( -clone 0 ) -geometry -4+0 -composite ^
( -clone 0 ) -geometry -8+0 -composite ^
( -clone 0 ) -geometry -16+0 -composite ^
( -clone 0 ) -geometry -32+0 -composite ^
( -clone 0 ) -geometry -64+0 -composite ^
( -clone 0 ) -geometry -128+0 -composite ^
-background White -compose Over -layers flatten ^
1.png ^
-compose CopyOpacity -composite ^
2.png
How can I change the background to a picture are not white, and black?
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

Tell me, please , why not work?

Code: Select all

for %%i in (a0\*) do (
	ImageMagick\convert ^
	"%%i" ^
	-alpha background ^
	-alpha off ^
	-transparent White ^
	-compose DstOver ^
	( -clone 0 ) -geometry +1+0 -composite ^
	( -clone 0 ) -geometry +2+0 -composite ^
	( -clone 0 ) -geometry +4+0 -composite ^
	( -clone 0 ) -geometry +8+0 -composite ^
	( -clone 0 ) -geometry +16+0 -composite ^
	( -clone 0 ) -geometry +32+0 -composite ^
	( -clone 0 ) -geometry +64+0 -composite ^
	( -clone 0 ) -geometry +128+0 -composite ^
	-background White -compose Over -layers flatten ^
	"%%i" ^
	-compose CopyOpacity -composite ^
	"a1\%%~nxi"
)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Working with alpha channel

Post by snibgo »

Escape the parentheses:

Code: Select all

   ^( -clone 0 ^) -geometry +1+0 -composite ^
snibgo's IM pages: im.snibgo.com
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

Thank you very much!

And the last question, how to make a picture like this?

Image

How can I change the background to a picture are not white, and black?
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

Tell me, please, in the next issue.

There is the original image with an alpha channel.

Image

Tell me, how do I do it like this, while preserving the alpha channel of the image.

Image

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

Re: Working with alpha channel

Post by snibgo »

The main effect in the second is a shift-fill. That is, the image is placed over a copy of itself shifted in one direction, and this is repeated.

Here's the same image shift-filled downwards then right-wards:
Image

The first image looks like a blur-fill.
snibgo's IM pages: im.snibgo.com
lorents
Posts: 42
Joined: 2010-07-06T04:27:53-07:00
Authentication code: 8675308

Re: Working with alpha channel

Post by lorents »

I thank for the answer!
Prompt and whether it is possible to make so in images?
Post Reply