Page 1 of 1

Newbie Question I'm sure...

Posted: 2007-08-15T19:47:20-07:00
by wortell
I'm trying to create a Reflection from an image and 'append' it below it...
now, naturally, i'm coming into some issues... but i'm breaking it down to the basics, and after 8 hours, i'm pulling my hair out - so before I go bald, i figured i'd break down, register on this forum, and inquire - hate to bother you experts in here! ;)

Whenever I get my final images on using the convert -composite combos, i'm getting a lot of black appearing - in my .png images... not sure why... but i broke it down to a basic issue, that won't require me to dump all my code here...

in the plethora of examples on this software - which i love!... i found this, and it doesn't work...

Code: Select all

system("exec 2>&1; convert-orig \
	-size 100x100 gradient:firebrick-none gradient_transparent.png");
this gives me a solid "firebrick" box only...

am I doing something wrong?

*** in addition ***
Plus, say I've got an image (IMAGE-1), and I wanted to create a reflection for it... with full transparency - for those using Mozilla and/or IE7 (or ie6 God forbid with a png fix .js file :) )....
the point being... how would i do this.. i believe I'm 98% there, but just not getting it...

Code: Select all

$img1="-size $size_dim gradient: -sigmoidal-contrast 8,50% ";
$IMAGE-1=$img_olay;
system("exec 2>&1; convert-orig \
	-size $size_dim xc:none \
	$blank");

system("exec 2>&1; convert-orig \
	$blank $IMAGE-1 $img1 -background none \
	+matte  -composite   final.png");
many thanks for any replies... :)

Bill (Dearborn Heights, MI, USA)

Re: Newbie Question I'm sure...

Posted: 2007-08-15T20:12:47-07:00
by anthony
wortell wrote:

Code: Select all

system("exec 2>&1; convert-orig \
	-size 100x100 gradient:firebrick-none gradient_transparent.png");
this gives me a solid "firebrick" box only...

am I doing something wrong?
No, your image should have transparency, if you IM is version is later than... 6.2.9-8

If it isn't upgrade. If it is your image viewer probably does not understand transparency.

Re: Newbie Question I'm sure...

Posted: 2007-08-16T07:37:52-07:00
by wortell
anthony wrote:
wortell wrote:

Code: Select all

system("exec 2>&1; convert-orig \
	-size 100x100 gradient:firebrick-none gradient_transparent.png");
this gives me a solid "firebrick" box only...

am I doing something wrong?
No, your image should have transparency, if you IM is version is later than... 6.2.9-8

If it isn't upgrade. If it is your image viewer probably does not understand transparency.

I'm sure your 100% right - and i'm very familiar with browswer transp issues... i'll dbl check on the installation of IM. I cannot use the -distorts I know...i'm hingent upon FANTASTICO updating their version of IM. :) it's below 6.3 I know! :)

Re: Newbie Question I'm sure...

Posted: 2007-08-16T17:10:37-07:00
by anthony
If it is not posible then the best idea is to generate your solid color firebrick image
but then generate a greyscale gradient to set transparency channel to (use copyopacity alpha composition).

Re: Newbie Question I'm sure...

Posted: 2007-08-17T08:38:48-07:00
by wortell
anthony wrote:If it is not posible then the best idea is to generate your solid color firebrick image
but then generate a greyscale gradient to set transparency channel to (use copyopacity alpha composition).
almost HATE to ask you to do this, can you point me to an example on your site or a quick code markup... i know, i'm sorry, i'm still getting the hang of this a bit, but i'm starting to get it. :)

Re: Newbie Question I'm sure...

Posted: 2007-08-17T08:51:19-07:00
by wortell
wortell wrote:
anthony wrote:If it is not posible then the best idea is to generate your solid color firebrick image
but then generate a greyscale gradient to set transparency channel to (use copyopacity alpha composition).
almost HATE to ask you to do this, can you point me to an example on your site or a quick code markup... i know, i'm sorry, i'm still getting the hang of this a bit, but i'm starting to get it. :)
sorry, i didn't realize how detailed your remarks really were - if you have time, great... if not, i think i might have it... :) i'll post it here for others if they have same issues, when I complete it... thanks.

Re: Newbie Question I'm sure...

Posted: 2007-08-17T09:16:14-07:00
by wortell
as promised, here's the quick code:

Code: Select all

system("exec 2>&1; convert-orig \
	-size 100x100 xc:firebrick \
	grad.png");

system("exec 2>&1; convert-orig \
	-size 100x100 gradient: \
	gradT.png");

system("exec 2>&1; \
	composite gradT.png grad.png -compose CopyOpacity \
	thisworks.png");
this produces the gradient:firebrick-none as described in your examples on your site (and in the above posts) for those who do not have 6.2.9 insalled/higher...

HOWEVER, now my question comes into why the mask doesn't work...

I created a simple image as follows:

Code: Select all

system("exec 2>&1; convert-orig \
	-size 100x100 xc:black -fill white -draw \"rectangle 10,10,50,50\" \
	mask.png");
and it produces an offcentered rectangle in the 100x100 box perfectly...
i was assuming that since it's a black-white image - that I could plainly use that in the method above as a mask... as follows:

Code: Select all

system("exec 2>&1; \
	composite gradT.png grad.png mask.png -compose CopyOpacity \
	thisworks.png");
HOWEVER, this actually produces the exact same image as GRAD.png (full 100x100 firebrick)... huh?

NOT sure what I'm doing wrong - as this seemed clearly illustrated in the 3 options of Alpha Composition Methods described here -> http://www.imagemagick.org/Usage/compose/#compose.

I know i could use a separate "compose" and use the "Dst_In" option, but, i really would love to be able to do that in one step! :)

-------
changed the mask to be

Code: Select all

xc:none 
instead of

Code: Select all

xc:black
and it worked ALMOST right... i still get that masked image but full FIREBRICK, not a faded version of it... i'm off to try a combo dst_in...
-------
yep that did it, but still had to do it in 2 commands... better than nothing... but is there a way I can do it in one command - ;) Anthony?? :)

here's what I wound up doing...

Code: Select all

system("exec 2>&1; \
	composite gradT.png grad.png -compose CopyOpacity \
	thisworks.png");

[code]system("exec 2>&1; \
	composite mask.png thisworks.png -compose Dst_In \
	cutout.png");
this gives me a cutout (2nd-ry mask) of the 'thisworks.png' gradient of the firebrick.

agian, i'd be interested in how to do this in ONE fell swoop! :)

Re: Newbie Question I'm sure...

Posted: 2007-08-18T05:21:51-07:00
by anthony
CopyOpacity is trick, for it to use a greyscale mask you have to turn of any transparency in the mask. As you are replacing the transparency in the destination image, it does not hurt to turn off the transparency in that image too. CopyOpacity readd it anyway as part of its defination..

So add +matte...

Code: Select all

 composite gradT.png grad.png +matte -compose CopyOpacity  thisworks.png
Or if you like to do it in convert (so you can combine commands do...

Code: Select all

convert grad.png grad T.png +matte -compose CopyOpacity -composite thisworks.png
Note the swapping of the image order in convert.

For details see IM examples, but explore your options in there.

http://www.imagemagick.org/Usage/compose/#copyopacity

OR for more mask handling, including blending image basied on a mask, see
http://www.imagemagick.org/Usage/channels/#masks

In future, start with IM Examples :-)

Re: Newbie Question I'm sure...

Posted: 2007-08-20T07:33:52-07:00
by wortell
anthony wrote:CopyOpacity is trick, for it to use a greyscale mask you have to turn of any transparency in the mask. As you are replacing the transparency in the destination image, it does not hurt to turn off the transparency in that image too. CopyOpacity readd it anyway as part of its defination..

So add +matte...

Code: Select all

 composite gradT.png grad.png +matte -compose CopyOpacity  thisworks.png
Or if you like to do it in convert (so you can combine commands do...

Code: Select all

convert grad.png grad T.png +matte -compose CopyOpacity -composite thisworks.png
Note the swapping of the image order in convert.

For details see IM examples, but explore your options in there.

http://www.imagemagick.org/Usage/compose/#copyopacity

OR for more mask handling, including blending image basied on a mask, see
http://www.imagemagick.org/Usage/channels/#masks

In future, start with IM Examples :-)
In short, I understand 96% (+/- :D ) of what you're talking about, and (like I said in the previous post), I get the correct transparency via the opacity command, but how do i get he COMBINATION of doing the above (what you said - and which I already implemented as stated in the prev. post at the bottom) while ALSO doing the * MASKING * at the same time... in other words making it a one-time command while also incorporating hte mask.png file as well...thanks... :)

Re: Newbie Question I'm sure...

Posted: 2007-08-21T00:19:46-07:00
by anthony
You see where convert reads in the results of a previous image....
Replace that with the convert command options that was used to create that image.
You may need to add parenthesis around those options...

Okay..

Code: Select all

   convert  -size 100x100  xc:firebrick \
           gradient: \
           +matte -compose CopyOpacity \
           result.png
ithe first line creates a soild color image
the secodn creates a gradient that same size
the thrid makes that gradient the transparency channel of the first image
the last line saves the results.

A simplified method use more complex operators is...

Code: Select all

    convert  -size 100x100 gradient: -background firebrick \
         compose CopyOpacity  -flatten   result.png
See IM examples on Flatten and the next second on multi-layer composition, and figure it out!!!! http://www.imagemagick.org/Usage/mosaics/#flatten

Re: Newbie Question I'm sure...

Posted: 2007-08-21T07:08:32-07:00
by wortell
anthony wrote:You see where convert reads in the results of a previous image....
Replace that with the convert command options that was used to create that image.
You may need to add parenthesis around those options...

Okay..

Code: Select all

   convert  -size 100x100  xc:firebrick \
           gradient: \
           +matte -compose CopyOpacity \
           result.png
ithe first line creates a soild color image
the secodn creates a gradient that same size
the thrid makes that gradient the transparency channel of the first image
the last line saves the results.

A simplified method use more complex operators is...

Code: Select all

    convert  -size 100x100 gradient: -background firebrick \
         compose CopyOpacity  -flatten   result.png
See IM examples on Flatten and the next second on multi-layer composition, and figure it out!!!! http://www.imagemagick.org/Usage/mosaics/#flatten

while i'm not trying to frustrate you into thinking that i don't 'figure things out' - i think my wording is confusing you... i understand what you've said already (see my previous posts) - i actually already did what you've said to do :).

The point is... it takes me TWO steps to do what I believe might be done in one step - see the post on (Posted: Mon Aug 20, 2007 10:33 am). :)???