Page 1 of 1

Change transparent color and -page not work.

Posted: 2009-01-07T09:56:09-07:00
by DannyGM
Hello

I have two questions

1:
I trying to change the trasnparent color (without -fill).

Code: Select all

convert -size 100X100 xc:none -alpha off -transparent-color blue -fill yellow -draw "circle 50,50 20,20" -blur 5X10 win:
This what i get:
Image

Why the background color it's black? I want it to be blue!

------------------------------
2:
I am trying to compose two images and set the offset of the second image.

Code: Select all

convert -size 100X100 xc:red -size 50X50 -page +20+20 xc:blue -composite win:
Image
Why the second image (xc:red) always sit on the upper left corner?

Sorry about my grammar, English isn'y my tang.

Thank you.

Re: Change transparent color and -page not work.

Posted: 2009-01-07T10:27:58-07:00
by el_supremo
Try this:

Code: Select all

convert -size 100X100 xc:red -size 50X50  xc:blue -geometry +20+20 -composite win:
Pete

Re: Change transparent color and -page not work.

Posted: 2009-01-07T10:29:47-07:00
by magick
Try this command:
  • convert -size 100X100 xc:red -size 50X50 xc:blue -geometry +20+20 -composite win:
The geometry option sets the offset when compositing.

Re: Change transparent color and -page not work.

Posted: 2009-01-07T11:24:16-07:00
by DannyGM
Thank you for your fast answer.

Now it's work.

What about changing the transparent color of object?

Re: Change transparent color and -page not work.

Posted: 2009-01-08T19:57:58-07:00
by anthony
I trying to change the trasnparent color (without -fill).

Code: Select all

convert -size 100X100 xc:none -alpha off -transparent-color blue -fill yellow -draw "circle 50,50 20,20" -blur 5X10 win:
This what i get:
Image

Why the background color it's black? I want it to be blue!
It is black as you used a canvas color of 'none' then turned off the transparency channel on the very next option! 'none' is defined as fully-transparency-black. so the result of that was a starting canvas of just black.

-transparent-color for NOT change the image at all. it just sets the color that is to be used for the transparent color index in the GIF color table. It basically defined the normally undefined color for older applications that ignore the GIF transparency features, of the file format.

That is it does NOTHING for you.
I am trying to compose two images and set the offset of the second image.

Code: Select all

convert -size 100X100 xc:red -size 50X50 -page +20+20 xc:blue -composite win:
Image
Why the second image (xc:red) always sit on the upper left corner?
The second image is blue, so I assume you ment xc:blue.

the problem you have is the usage difference between a -page (or virtual canvas offset) and -geometry (or alpha composition offset)
What is used depends on what type of operation you are applying,

-page is used for sequences of images to align those images relative to each other. That is image Layering, and Animations. It is not -gravity effected.

-geometry is -gravity effected so you can center or placing images relative to to say the bottom or right edges. It is used specifically for alpha composition (which usually ignores -page offsets)

See IM Examples... Alpha Composition
Composite Geometry/Gravity Settings
vs Layer Canvas/Page Offsets
http://www.imagemagick.org/Usage//compose/#geometry

Lots of links here to both layer and alpha composition methods.
though more general use of both can be found in the 'Layering Images" area of IM Examples
http://www.imagemagick.org/Usage/layers/

Note that one operator actually uses BOTH simultaneously.
-layers composite which merges two separate sequences of images with relative -page offsets together, using a global -geometry offset (relative to the virtual canvas size) to position the two sequences.

See IM examples
Animation/Layer Composition
http://www.imagemagick.org/Usage/anim_mods/#composite

Thank you Anthony

Posted: 2009-01-10T10:39:19-07:00
by DannyGM
Thank you Anthony.

Here is my code, for changing the transparenr color

Code: Select all

convert  logo: ( -size 500X500 xc:blue -transparent blue -fill yellow
-draw "circle 200,200 50,50" -blur 5X10 )  -gravity west  -composite  -resize 200X200 candelete.jpg
Image

Re: Thank you Anthony

Posted: 2009-01-11T16:55:10-07:00
by anthony
DannyGM wrote:Thank you Anthony.

Here is my code, for changing the transparenr color

Code: Select all

convert  logo: ( -size 500X500 xc:blue -transparent blue -fill yellow
-draw "circle 200,200 50,50" -blur 5X10 )  -gravity west  -composite  -resize 200X200 candelete.jpg
Ok you create a canvas, make it blue, then make the blue transparent, draw a yellow circle and blur it (without using -channel RGBA)

The result would in all likely hood NOT have a transparent blue. Mathematically transparent colors are undefined, and as a result generally get reset to transparent black. so that canvas will probably NOT be quite what you expect, and is likely to vary a lot from IM version to IM version.

I repeat full-transparency color is undefined, and how operators handle it is also undefined.

See the examples in blur with transparency
http://www.imagemagick.org/Usage/convolve/#blur_channel

What exactly are you wanting???? a yellow circle bluring out to a bluish semi-transparency and then full-transparency?

The best way to gurantee this is to handle the color and alpha channel separatally.

\( -size 500X500 xc:blue -fill yellow -draw "circle 200,200 50,50" \
\( xc:black -fill white -draw "circle 200,200 50,50" \) \
-blur 0x20 +matte -compose CopyOpacity -composite \)

NOTE the extra internal parenthesis for the second draw!

Now that will have a yellow circle with a blue semi-transparency.
Guranteed, and does not relay on any semi-transparent color remaining something it isn't.

In fact it will produce a higher quality result as the draw will create an anti-aliased yellow-blue color border even BEFORE the blur adds to the effect!

A simplier way is to just blue a blue border with a properly handled transparency blur (ignore transparent colors correctly)

-size 500x500 -xc:none -fill yellow -stroke blue -strokewidth 10 \
-draw "circle 200,200 50,50" -channel RGBA -blur 0x10

probably a LOT simplier to generate too!


Transparency is tricky. and relying on transparency to have a specific color is a BAD idea... period.

WARNING: as yellow is a complement of blue in RGB space the transparency shading may not be what you expect, as yellow will shade to black, in the red and green channel, while blue shades from black to semi-transparent blue to full-transparency.

As a result you will probably get a yellow - darkgray - blue - transparent gradient.

you can see this using a yellow-blue gradient image

convert -size 50x400 gradient:yellow-blue show:

Note the dark gray in the middle caused by RGB color space