This project has moved. For the latest updates, please go here.

Magick Script & Composite

Mar 6, 2014 at 11:50 AM
Hi,

Thank you very much for your perfect work.
How can i used Composite in Magick Script ?

Like this :
                MagickImage futmask2 = new MagickImage(System.Drawing.Color.Black, 850, 340);
                
                string func3 = "xcercle=(i-(850)/2)/((850+50)) ; ycercle = sqrt(1-xcercle^2);  ymax=abs(xcercle)>1?0:ycercle  ;ymax";
                futmask2.Fx(func3);
                futmask2.Write("out\\futmask2.png");

                MagickImage test = new MagickImage(filein);
                test.VirtualPixelMethod = VirtualPixelMethod.Transparent;
                test.BackgroundColor = MagickColor.Transparent;
                
                test.Composite(futmask2, 0, 0, CompositeOperator.Darken);
                test.Write("out\\base2.png");
Coordinator
Mar 6, 2014 at 9:03 PM
You can read the mask directly in the script when you specify the file name (the commented part) or you can use the 'Read' event to load the image. Below is an example that uses the Read event.

script.msl
<msl>
  <read>
    <virtualPixelMethod value=""Transparent""/>
    <backgroundColor value=""Transparent""/>
    <composite x=""0"" y=""0"" compose=""Darken"">
      <!--<image fileName=""out\\futmask2.png""/>-->
      <image id=""mask""/>
    </composite>
  </read>
</msl>"
static void ExecuteScript()
{
  MagickScript script = new MagickScript("script.msl");
  script.Read += script_Read;

  using (MagickImage test = new MagickImage(filein))
  {
    script.Execute(test);
    test.Write("out\\base2.png");
  }
}
static void script_Read(object sender, ScriptReadEventArgs arguments)
{
  if (arguments.Id == "mask")
  {
    MagickImage futmask2 = new MagickImage(System.Drawing.Color.Black, 850, 340);

    string func3 = "xcercle=(i-(850)/2)/((850+50)) ; ycercle = sqrt(1-xcercle^2);  ymax=abs(xcercle)>1?0:ycercle  ;ymax";
    futmask2.Fx(func3);
    arguments.Image = futmask2;
  }
}
Mar 7, 2014 at 1:32 PM
Thank you very much !
Mar 28, 2014 at 4:10 PM
Edited Mar 28, 2014 at 4:11 PM
Hi,

in this exemple :
<msl>
  <read>
    <virtualPixelMethod value=""Transparent""/>
    <backgroundColor value=""Transparent""/>
    <composite x=""0"" y=""0"" compose=""Darken"">
      <!--<image fileName=""out\\futmask2.png""/>-->
      <image id=""mask""/>
    </composite>
  </read>
</msl>
Can i extend the second image (out\futmask2.png or id=mask) inside the same script before the composite ?

USWebCoatedSWOP isn't available in enumeration ?
 <addProfile>
      <colorProfile name="USWebCoatedSWOP"/>
    </addProfile>
Best regards,
Coordinator
Mar 28, 2014 at 8:08 PM
I forgot to add the recently added colorprofiles to the MagickScript enumeration. I will fix this in the next release of Magick.NET.

What do you mean by extend the second image, do you want to do something like this:
<msl>
  <read>
    <composite x="0" y="0" compose="Darken">
      <image id="mask">
        <addProfile>
          <colorProfile name="USWebCoatedSWOP"/>
        </addProfile>
      </image>
    </composite>
  </read>
</msl>
Mar 31, 2014 at 8:01 AM
Like This :
<msl>
  <read>
    <composite x="0" y="0" compose="Darken">
      <image id="mask">
         <extent width="100" height="100" gravity="Center" backgroundColor="#fff" />      
      </image>
    </composite>
  </read>
</msl>
Coordinator
Apr 1, 2014 at 2:12 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.