<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Rule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Rule_Axmedis.xsd">
  <Header>
    <Rule_Name>multigeneration</Rule_Name>
    <AXRID>axcprule:230472ad-3c4d-43a9-987c-2dfc06887f37</AXRID>
    <Rule_Version>1.0</Rule_Version>
    <Rule_Type>AXCP</Rule_Type>
    <Software_Name></Software_Name>
    <Version_of_software></Version_of_software>
    <Date_of_production>2006-01-17</Date_of_production>
    <Author></Author>
    <Affiliation></Affiliation>
    <URL></URL>
    <Comment></Comment>
    <Last_Modifications>2006-07-06</Last_Modifications>
    <Terminal_ID></Terminal_ID>
    <Cost></Cost>
    <Work_Item_ID></Work_Item_ID>
  </Header>
  <Schedule>
    <Run>
      <Date>2006-03-10</Date>
      <Time>12:35:49</Time>
      <Periodicity Unit="Minute">2</Periodicity>
      <Expiration_Date>2007-01-17</Expiration_Date>
      <Expiration_Time>17:33:49</Expiration_Time>
    </Run>
    <Status>Inactive</Status>
  </Schedule>
  <Definition>
    <AXCP_Rule>
      <Arguments>
        <Parameter Name="res" Type="String">axmedis_logo.png</Parameter>
        <Parameter Name="resourcePath" Type="String">C:\axexamples\ruleditor\resources\</Parameter>
        <Parameter Name="h" Type="Integer">320</Parameter>
        <Parameter Name="w" Type="Integer">200</Parameter>
        <Parameter Name="maxDoc" Type="Integer">10</Parameter>
      
      </Arguments>
      <Rule_Body>
        <JS_Script name="main"><![CDATA[/***************************************************************************/
// AXMEDIS JSScript
// This script is provided merely as demonstration tools and provide 
// limited functionalities and robustness with respect to the full tools, 
// and as such should be considered. 
// AXMEDIS declines any responsibility on the use made with the script 
// hereby installed.
// The intellectual property of this script belongs to AXMEDIS, and 
// any total or partial reproduction of it is prohibited 
// without written authorization of AXMEDIS Consortium. 
// AXMEDIS Copyright 2006.

// Please verify the resourcePath value before running the script
// Fix it to the right path (double clicking on the item to open
// the editing dialog)
/**************************************************************************/


// Function for converting Raw Images
function adaptRawImages(path,height,width,format)
{
  var h = new Array(1);
  var w = new Array(1);
  h[0]=0;
  w[0]=0;
  print("Creating adapted image");   
  var imgResource = new AxResource()
  imgResource.load(path);
  if(imgResource.mimeType.search("image")==0)
  {
          print("Converting the resource in "+format);
          ImageProcessing.GetInfo(imgResource,h,w);
          print("Original size "+h+"x"+w);
          ImageProcessing.Resize(imgResource,height,width,false,imgResource);
          print("Resized to "+height+"x"+width);
          if(imgResource.mimeType!=format)
          {
              ImageProcessing.Conversion(imgResource,format,imgResource);
          }
          imgResource.save(resourcePath+title);
  } 
}

// Function for creating the Axmedis Object by composing and converting resources
function test()
{
   var outputPath = resourcePath;

   var imgFormats = new Array();
   imgFormats[0] = getMimeType("gif");
   imgFormats[1] = getMimeType("jpg");
   imgFormats[2] = getMimeType("png");
   imgFormats[3] = getMimeType("tif");
   imgFormats[4] = getMimeType("bmp");
   imgFormats[5] = getMimeType("pdf");
  
 
  var i = 0;
  for (i=0; i<maxDoc; i++)
  {
      h0 = h*(i+1)/20;
      w0 = w*(i+1)/20;
      for(j=0; j<imgFormats.length; j++)
      {   
         title = "Example_"+i+"_"+j;
         adaptRawImages(resourcePath+res,h0,w0,imgFormats[j]);
      }
  }
  return true;
  
}

//Entry point of the script
test();]]>
        </JS_Script>
      </Rule_Body>
      <Dependencies>
        <Dependency>
          <Plug_In_name>ImageProcessing</Plug_In_name>
          <Version>1.001</Version>
        </Dependency>
      </Dependencies>
    </AXCP_Rule>
  </Definition>
</Rule>

