AE　インスタフレーム作成スクリプト

#自動で作成インスタフレームコンポジション
特に難しい事はしてないのですが、インスタの作成は需要があるかなと思い作成してみました。
ただ作っていくなかで、スライドショーのエクスプレッションを書いていたらいい感じの物が出来たので
どちらかというとそちらを見てほしいなと思います。
動画はこちらからご覧ください。
https://youtu.be/LhB136Iy1PI

今回のスクリプトも載せておきます。

```jsx
﻿/*
script written by timetoedit.net
http://www.timetoedit.net/
*/
 
//localize
var widthStr = { ja:"幅 :",en:"width :"};
var heightStr = { ja:"高さ :",en:"height :"};
var frameRatioStr = { ja:"フレーム比率 :",en:"frame Ratio :"};
var pixelAspectStr ={ ja:"ピクセル縦横比:",en:"Pixel Aspect Ratio :"};
var frameRateStr ={ ja:"フレームレート:",en:"Frame Rate :"};
var userStr ={ ja:"ユーザー名:",en:"User Name :"};
var profPicStr ={ ja:"プロフィール写真を選択して下さい",en:"Profile Picture"};
//初期変数
var headerComp;
var iconSize;
var areaSplitParesent =[10,80,10]//header,main,footer
var instagramFolder;
var commonFolder;
var compFolder;
var picsFolder;
var CompSize =[];// InstagraFrameCompSize
var CA_headerSize =[];
var CA_PicsSize =[];
var CA_footerSize =[];
var commonPaddingWidth =98 ;//共通のパディング幅 compsize[1]のn%
var commonMarginSize;
var hfPaddingSize; //ヘッダーとフッターのパディング
var commonhfPaddingSizeWidth =90 ;//共通のパディング幅 compsize[1]のn%
var shapeScall = 50;
var footerIconMargin;
var shapeStrokeWidthNum = 1;
var shapeStrokeWidth;
var ratio= [
    [15,16,"minor second",1.067],
    [8,9,"major second",1.125],
    [5,6,"minor third",1.2],
    [4,5,"major third",1.25],
    [3,4,"perfect fourth",1.333],
    [1,Math.SQRT2,"aug. fourth / dim. fifth",1.414],
    [2,3,"perfect fifth",1.5],
    [5,8,"minor sixth",1.6],
    [1,1.618,"golden section",1.618],
    [3,5,"major sixth",1.667],
    [9,16,"minor seventh",1.778],
    [8,15,"major seventh",1.875],
    [1,2,"octave",2],
//~     [2,5,"major tenth",2.5],
//~     [3,8,"major eleventh",2.667],
//~     [1,3,"major twelfth",3],
//~     [1,4,"double octave",4],
]
 
var frameRate =[
8,
12,
15,
23.976,
24,
25,
29.97,
30,
50,
59.94,
60,
120,
]
 
{/////Script UI
    var winObj = (this instanceof Panel) ? this : new Window("palette", "Instagram Slide Show", undefined, {resizeable: true});
    //コンテンツグループ
    var contentsGrp =winObj.add('group',undefined,'contentsGrp');
    contentsGrp.orientation = 'column';
    //著作
     statictext = contentsGrp.add("statictext",undefined,"script written by timetoedit.net");
     
    //パネルグループ
    var instaPanel = contentsGrp.add("panel")
    instaPanel.text="Instagram Composition Setting"
    instaPanel.orientation = 'column';
    //ユーザー名
    UserTextGrp =  instaPanel.add('group',undefined,'boxleft');
    UserTextGrp.orientation = 'row';
    statictext = UserTextGrp.add("statictext",undefined,localize(userStr));
    useredittext = UserTextGrp.add("edittext",[0,0,200,20],"Instagram User Name");
    //幅高さグループ
    var whGrp = instaPanel.add('group',undefined,'whGrp');
    whGrp.orientation = 'row';
    //チェックボックス
    boxleftGrp =  whGrp.add('group',undefined,'boxleft');
    boxleftGrp.orientation = 'column';
    first = boxleftGrp.add("radiobutton",undefined,"");
    first.value = true;
    second = boxleftGrp.add("radiobutton",undefined,"");
    //スタティックテキスト
    boxTextGrp =  whGrp.add('group',undefined,'boxleft');
    boxTextGrp.orientation = 'column';
    boxTextGrp.alignChildren = "right";
    statictext = boxTextGrp.add("statictext",undefined,localize(widthStr));
    statictext = boxTextGrp.add("statictext",undefined,localize(heightStr));
    //エディットテキスト
    boxEditTextGrp =  whGrp.add('group',undefined,'boxleft');
    boxEditTextGrp.orientation = 'column';
    boxEditTextGrp.alignChildren = "right";
    widthedittext = boxEditTextGrp.add("edittext",[0,0,40,20],"350");
    heightedittext = boxEditTextGrp.add("edittext",[0,0,40,20],"350");
    heightedittext.enabled = false;//デフォルト
    //スタティックテキスト
    boxTextGrp =  whGrp.add('group',undefined,'boxleft');
    boxTextGrp.orientation = 'column';
    boxTextGrp.alignChildren = "left";
    statictext = boxTextGrp.add("statictext",undefined,"px");
    statictext = boxTextGrp.add("statictext",undefined,"px");
    //フレーム比率
    var IF_RatioSetting = instaPanel.add('group',undefined,'guiRatioSetting');
    statictext = IF_RatioSetting.add("statictext",undefined,localize(frameRatioStr));
    var ddl = IF_RatioSetting.add("dropdownlist");
        for (i=0; i<ratio.length;i++){
            ddl.add("item",ratio[i][0]+":"+ratio[i][1]+"-"+ratio[i][2])
        }
    ddl.selection = 5;
    //ピクセル縦横比
    var SCP_pixel = instaPanel.add('group',undefined,'FCP_height');//parent
    statictext = SCP_pixel.add("statictext",undefined,localize(pixelAspectStr));
    pixeledittext = SCP_pixel.add("edittext",[0,0,40,20],"1")
 
    var SlideshowCompRatioSetting = instaPanel.add('group',undefined,'guiRatioSetting');
    statictext = SlideshowCompRatioSetting.add("statictext",undefined,localize(frameRateStr));
    var ddlTwo = SlideshowCompRatioSetting.add("dropdownlist");
        for (i=0; i<frameRate.length;i++){
            ddlTwo.add("item",frameRate[i])
        }
    ddlTwo.selection = 7;
    //ボタン
    var buttonGrp = contentsGrp.add('group',undefined,'FCP_height');//parent
    buttonGrp.orientation = 'row';
    //var testBtn = buttonGrp.add("button",undefined,"Test");
    var btn = buttonGrp.add("button",undefined,"実行");
}
 
winObj.onResizing = winObj.onResize = function () {this.layout.resize();};  
if (winObj instanceof Window) {  
            winObj.center();  
            winObj.show();  
        } else {  
            winObj.layout.layout(true);  
            winObj.layout.resize();  
        }  
 
{//Actions
    btn.onClick = function(){
        GetCompSize(first.value);
        GetContentsAreaSize()
        if (!flagCheck()){return false;};
        app.beginUndoGroup("instagram");
        createFolder()
        createIconSize ();
        createHeader();
        CreateComp();
        app.endUndoGroup();
    }
/*
    testBtn.onClick = function(){
    }
*/
    first.onClick = function(){
        first.value = true;
        second.value = false;
        widthedittext.enabled = first.value;
        heightedittext.enabled = second.value;
    }
    second.onClick = function(){
        first.value = false;
        second.value = true;
        widthedittext.enabled = first.value;
        heightedittext.enabled = second.value;
    }
}
 
//functions
//コンポジションのサイズを取得
function GetCompSize(flag){
    CompSize =[];
    if (flag == true){
        var tempwidth = Number (widthedittext.text);
        var tempheight = (tempwidth*ratio[ddl.selection.index][1])/ratio[ddl.selection.index][0];
    }else{
        var tempheight = Number(heightedittext.text)
        var tempwidth = (tempheight*ratio[ddl.selection.index][0])/ratio[ddl.selection.index][1];
    }
    CompSize.push(Math.round(tempwidth),Math.round(tempheight));
}
//3カラムのサイズ取得
function GetContentsAreaSize(){
    //配列空にする
    CA_headerSize =[];
    CA_PicsSize =[];
    CA_footerSize =[];
    //header
    var x = CompSize[0]/100*commonPaddingWidth;
    var y =  CompSize[1]/100*areaSplitParesent[0];
    CA_headerSize.push(Math.round(x),Math.round(y));
    //main
    var x = CompSize[0]/100*commonPaddingWidth;
    var y =  CompSize[1]/100*areaSplitParesent[1];
    CA_PicsSize.push(Math.round(x),Math.round(y));
    //footer
    var x = CompSize[0]/100*commonPaddingWidth;
    var y =  CompSize[1]/100*areaSplitParesent[2];
    CA_footerSize.push(Math.round(x),Math.round(y));
    //共通のマージンサイズを取得
    commonMarginSize = (CompSize[0]-(CompSize[0]/100*commonPaddingWidth))/2;
    hfPaddingSize = (CompSize[0]-(CompSize[0]/100*commonhfPaddingSizeWidth))/2;
    footerIconMargin =ParsentCalculation(CompSize[0],3)//アイコン同士の間隔
    shapeStrokeWidth = ParsentCalculation(CompSize[0],shapeStrokeWidthNum)
}
//プロジェクトアイテム選択チェック
function flagCheck(){
    n = app.project.selection.length;
    if (n <= 0){
        alert("写真を選択して下さい");
        return false;
    }
    for(i=0; i<n; i++){
        if (stillcheck(app.project.selection[i]) == false){
            alert(app.project.selection[i].name+"は写真ではありません");
            return false;
        }
    }
    return true;
}
//選択したものが写真かチェック
function stillcheck(target){
    if((target.mainSource instanceof FileSource) && (target.width > 0)){
        return target.mainSource.isStill;  
    }else{
        return false;
    }
}
//アイコンのサイズを決める引数２が比率
function createIconSize(){
    iconSize = ParsentCalculation(CA_headerSize[0],10);
}
//Headerのコンポジションを作成
function createHeader(){
    headerComp = app.project.items.addComp("Header",CompSize[0],CA_headerSize[1],pixeledittext.text,60,frameRate[ddlTwo.selection.index]);
    iconShape()
    addText(useredittext.text,headerComp,[0,0,0]);
    createDot()
    headerComp.parentFolder = headerFolder;
}
//インスタフレームコンポジション
function CreateComp(){
    var tempcomp;
    for(i=0; i<n; i++){
        var teampy =0 ;
        var myPics = app.project.selection[i];
        var name = myPics.name;
        tempcomp = app.project.items.addComp(name,CompSize[0],CompSize[1],pixeledittext.text,60,frameRate[ddlTwo.selection.index]);
        tempcomp.layers.addSolid([1,1,1],"BG", CompSize[0],CompSize[1],pixeledittext.text,60);//背景の平面レイヤー白を作成
        var header = tempcomp.layers.add(headerComp);
        teampy = CA_headerSize[1]/2;
        header.property("ADBE Transform Group").property("ADBE Position").setValue([CompSize[0]/2,teampy])
        setPicture(tempcomp,myPics)
        shapegrp(tempcomp)
        tempcomp.parentFolder = compFolder;
    }
}
 
function setfontSize( layer,num ){
    var td = layer.property("ADBE Text Properties").property("ADBE Text Document").value;
    td.fontSize = num;
    layer.property("ADBE Text Properties").property("ADBE Text Document").setValue(td)
}
function getTextWidthSize( layer ){
    var comp = layer.containingComp;  
    var curTime = comp.time;  
    var layerAnchor = layer.anchorPoint.value;  
    var x = layer.sourceRectAtTime(curTime, false).width/2;  
    x += layer.sourceRectAtTime(curTime, false).left;  
    var xAdd = (x-layerAnchor[0]) * (layer.scale.value[0]/100);  
    return x
}
function setAnchorPoint( layer ){  
    var comp = layer.containingComp;  
    var curTime = comp.time;  
    var layerAnchor = layer.anchorPoint.value;  
    var x = layer.sourceRectAtTime(curTime, false).width/2;  
    var y = layer.sourceRectAtTime(curTime, false).height/2;  
    x += layer.sourceRectAtTime(curTime, false).left;  
    y += layer.sourceRectAtTime(curTime, false).top;  
    var xAdd = (x-layerAnchor[0]) * (layer.scale.value[0]/100);  
    var yAdd = (y-layerAnchor[1]) * (layer.scale.value[1]/100);  
    layer.anchorPoint.setValue([ x, y ]);  
};  
function createDot(){
    var EllipseSizeNum = ParsentCalculation(CA_headerSize[0],1.5);
    var pad = ParsentCalculation(CA_headerSize[0],3);
    var pos = ParsentCalculation(CA_headerSize[0],3);
    var shapeLayer = headerComp.layers.addShape(); // adding a shape layer to the pipComp
    var contents = shapeLayer.property("ADBE Root Vectors Group"); // Accessing the contents of the shape layer
    var shapeEllipse = contents.addProperty("ADBE Vector Shape - Ellipse"); // Adding a rectangle to the shape layer
    var shapeFill = contents.addProperty("ADBE Vector Graphic - Fill");
    shapeFill.property("ADBE Vector Fill Color").setValue([0,0,0])
    shapeEllipse = contents.property("ADBE Vector Shape - Ellipse"); // adding fill invalidates shapeRect
    var EllipseSize = shapeEllipse.property("ADBE Vector Ellipse Size");
    var EllipsePosition = shapeEllipse.property("ADBE Vector Ellipse Position");
    var EllipseRoundness = shapeEllipse.property("ADBE Vector Ellipse Roundness");
    EllipseSize.setValue([EllipseSizeNum,EllipseSizeNum]);
    shapeLayer.property("ADBE Transform Group").property("ADBE Position").setValue([iconSize/2,CA_headerSize[1]/2]);
    var repprop = shapeLayer.property("ADBE Root Vectors Group").addProperty("ADBE Vector Filter - Repeater");
    shapeLayer.name = "dot"
    repprop.property("ADBE Vector Repeater Copies").setValue(3);
    repprop.property("ADBE Vector Repeater Offset").setValue(-1);
    repprop.property("ADBE Vector Repeater Transform").property("ADBE Vector Repeater Position").setValue([0,pad]);
    shapeLayer.property("ADBE Transform Group").property("ADBE Position").setValue([CA_headerSize[0]-(pos/2)-commonMarginSize-hfPaddingSize,CA_headerSize[1]/2])
}
function iconShape(){
    var shapeLayer = headerComp.layers.addShape(); // adding a shape layer to the pipComp
    var contents = shapeLayer.property("ADBE Root Vectors Group"); // Accessing the contents of the shape layer
    var shapeEllipse = contents.addProperty("ADBE Vector Shape - Ellipse"); // Adding a rectangle to the shape layer
    var shapeFill = contents.addProperty("ADBE Vector Graphic - Fill");
    shapeEllipse = contents.property("ADBE Vector Shape - Ellipse"); // adding fill invalidates shapeRect
    var EllipseSize = shapeEllipse.property("ADBE Vector Ellipse Size");
    var EllipsePosition = shapeEllipse.property("ADBE Vector Ellipse Position");
    var EllipseRoundness = shapeEllipse.property("ADBE Vector Ellipse Roundness");
    EllipseSize.setValue([iconSize,iconSize]);
    shapeLayer.property("ADBE Transform Group").property("ADBE Position").setValue([iconSize/2+commonMarginSize+hfPaddingSize,CA_headerSize[1]/2])
    shapeLayer.name = "alph"
}
function addText(string,targetComp,color){
    var mytext = targetComp.layers.addText(string);
    setfontSize( mytext,iconSize/2 )
    setAnchorPoint( mytext );
    mytext.position.setValue([getTextWidthSize(mytext)+iconSize+ParsentCalculation(CA_headerSize[1],10)+commonMarginSize+hfPaddingSize,CA_headerSize[1]/2]);
    //text fill color
    var td = mytext.property("ADBE Text Properties").property("ADBE Text Document").value;
    td.fillColor =color;
    mytext.property("ADBE Text Properties").property("ADBE Text Document").setValue(td)
    return mytext;
}
 
function setPicture(targetComp,targetlayer){
    var myPics = targetComp.layers.add(targetlayer);
    var piscAreaGuide = targetComp.layers.addSolid([0,1,1],"picsArea", CA_PicsSize[0],CA_PicsSize[1],pixeledittext.text,60);
    myPics.trackMatteType = TrackMatteType.ALPHA;
    myPics.property("ADBE Transform Group").property("ADBE Scale").setValue([picsfitscall(myPics),picsfitscall(myPics)])
    //positionの設定
    piscAreaGuide.property("ADBE Transform Group").property("ADBE Position").setValue([CompSize[0]/2,CA_headerSize[1]+(CA_PicsSize[1]/2)])
    myPics.property("ADBE Transform Group").property("ADBE Position").setValue([CompSize[0]/2,CA_headerSize[1]+(CA_PicsSize[1]/2)])
}
function picsfitscall(layer){
    var picXsize = layer.width;
    var picYsize = layer.height;
    var x = CA_PicsSize[0]/picXsize*100;
    var y = CA_PicsSize[1]/picYsize*100;
    var result = Math.max(x,y);
    return result
}
 
//Shapes
function shapegrp(targetComp){
    var tempx;
    function hartObj(targetComp){
    var Obj = new Object();
    Obj.Path = [
    [49.5050048828125,-17.6569976806641],
    [0.00001525878906,-26.2379913330078],
    [-49.5050048828125,-17.6569976806641],
    [0.00001525878906,49.0099945068359],
    ]
    Obj.inTangents = [
    [7.26100158691406,31.3529968261719],
    [8.58099365234375,-20.1320037841797],
    [7.26100158691406,-31.3529968261719],
    [0,0],
    ]
    Obj.outTangents = [
    [-7.26100158691406,-31.3529968261719],
    [-8.58100891113281,-20.1320037841797],
    [-7.26100158691406,31.3529968261719],
    [0,0],
    ]
    var addshape = targetComp.layers.addShape();
    addshape.name = "hartObj";
    var sShape = new Shape(); 
    sShape.vertices = Obj.Path;
    sShape.inTangents = Obj.inTangents;
    sShape.outTangents = Obj.outTangents;
    sShape.closed = true;
    var grp1 = addshape.content.addProperty("ADBE Vector Group");
    var grp2 = grp1.content.addProperty("ADBE Vector Shape - Group");
    grp2.property("ADBE Vector Shape").setValue(sShape);
    commonShapeSetting(addshape);
    tempx = commonMarginSize+hfPaddingSize+(shapePathFitScall(addshape)[0]/2);
    var y = CA_headerSize[1]+CA_PicsSize[1]+(CA_footerSize[1]/2);
    addshape.property("ADBE Transform Group").property("ADBE Position").setValue([tempx,y]);
    return addshape
    }
 
    function commentObj(targetComp){
    var Obj = new Object();
    Obj.Path = [
    [39.12451171875,22.552001953125],
    [45.1645050048828,0],
    [0.00050354003906,-45.1640014648438],
    [-45.1645050048828,0],
    [0.00050354003906,45.1640014648438],
    [23.2434997558594,38.7279968261719],
    [45.1645050048828,44.7039947509766],
    ]
    Obj.inTangents = [
    [0,0],
    [0,8.21699523925781],
    [24.9430084228516,0],
    [0,-24.9430084228516],
    [-24.9430084228516,0],
    [-6.79100036621094,4.08399963378906],
    [0,0],
    ]
    Obj.outTangents = [
    [3.83499145507813,-6.63800048828125],
    [0,-24.9430084228516],
    [-24.9430084228516,0],
    [0,24.9440002441406],
    [8.50199890136719,0],
    [0,0],
    [0,0],
    ]
 
    var addshape = targetComp.layers.addShape();
    addshape.name = "commentObj";
    var sShape = new Shape(); 
    sShape.vertices = Obj.Path;
    sShape.inTangents = Obj.inTangents;
    sShape.outTangents = Obj.outTangents;
    sShape.closed = true;
    var grp1 = addshape.content.addProperty("ADBE Vector Group");
    var grp2 = grp1.content.addProperty("ADBE Vector Shape - Group");
    grp2.property("ADBE Vector Shape").setValue(sShape);
    commonShapeSetting(addshape)
    tempx =tempx + shapePathFitScall(addshape)[0]+footerIconMargin
    var y = CA_headerSize[1]+CA_PicsSize[1]+(CA_footerSize[1]/2)
    addshape.property("ADBE Transform Group").property("ADBE Position").setValue([tempx,y])
    return addshape
    }
 
    function paper(targetComp){
    var Obj = new Object();
    Obj.Path = [
    [50,-42.1670074462891],
    [-12.0919952392578,-8.4840087890625],
    [-50,-42.5],
    [50,-42.1670074462891],
    [-1.3070068359375,42.5],
    [-12.0919952392578,-8.4840087890625],
    ]
    Obj.inTangents = [
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    ]
    Obj.outTangents = [
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    ]
 
    var addshape = targetComp.layers.addShape();
    addshape.name = "paper";
    var sShape = new Shape(); 
    sShape.vertices = Obj.Path;
    sShape.inTangents = Obj.inTangents;
    sShape.outTangents = Obj.outTangents;
    sShape.closed = false;
    var grp1 = addshape.content.addProperty("ADBE Vector Group");
    var grp2 = grp1.content.addProperty("ADBE Vector Shape - Group");
    grp2.property("ADBE Vector Shape").setValue(sShape);
    commonShapeSetting(addshape)
    tempx =tempx + shapePathFitScall(addshape)[0]+footerIconMargin
    var y = CA_headerSize[1]+CA_PicsSize[1]+(CA_footerSize[1]/2)
    addshape.property("ADBE Transform Group").property("ADBE Position").setValue([tempx,y])
    return addshape
 
    }
 
    function ribbon(targetComp){
    var Obj = new Object();
    Obj.Path = [
    [35.8885040283203,42.1484985351563],
    [-0.00050354003906,7.09449768066406],
    [-35.8885040283203,42.1484985351563],
    [-35.8885040283203,0.00050354003906],
    [-35.8885040283203,-34.8284912109375],
    [-28.5695037841797,-42.1484985351563],
    [-0.00050354003906,-42.1484985351563],
    [28.5684967041016,-42.1484985351563],
    [35.8885040283203,-34.8284912109375],
    [35.8885040283203,0.00050354003906],
    ]
    Obj.inTangents = [
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [-4.0419921875,0],
    [0,0],
    [0,0],
    [0,-4.04299926757813],
    [0,0],
    ]
    Obj.outTangents = [
    [0,0],
    [0,0],
    [0,0],
    [0,0],
    [0,-4.04299926757813],
    [0,0],
    [0,0],
    [4.04299926757813,0],
    [0,0],
    [0,0],
    ]
 
    var addshape = targetComp.layers.addShape();
    addshape.name = "ribbon";
    var sShape = new Shape(); 
    sShape.vertices = Obj.Path;
    sShape.inTangents = Obj.inTangents;
    sShape.outTangents = Obj.outTangents;
    sShape.closed = true;
    var grp1 = addshape.content.addProperty("ADBE Vector Group");
    var grp2 = grp1.content.addProperty("ADBE Vector Shape - Group");
    grp2.property("ADBE Vector Shape").setValue(sShape);
    commonShapeSetting(addshape)
    var x = CompSize[0]-commonMarginSize-hfPaddingSize-(shapePathFitScall(addshape)[0]/2)
    var y = CA_headerSize[1]+CA_PicsSize[1]+(CA_footerSize[1]/2)
    addshape.property("ADBE Transform Group").property("ADBE Position").setValue([x,y])
    return addshape
 
    }
 
 
    function commonShapeSetting(shapeLay){
    shapeLay.property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").addProperty("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Width").setValue(shapeStrokeWidth);
    shapeLay.property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Color").setValue([0, 0, 0, 0]);
    shapeLay.property("ADBE Transform Group").property("ADBE Scale").setValue(shapePathFitScall(shapeLay))
    }
hartObj(targetComp)
commentObj(targetComp)
paper(targetComp)
ribbon(targetComp)
}
 
function shapePathFitScall(shapePath){
    var picXsize = shapePath.sourceRectAtTime(0, true).width;
    var picYsize = shapePath.sourceRectAtTime(0, true).height;
    var x = CA_footerSize[0]/picXsize*shapeScall;
    var y = CA_footerSize[1]/picYsize*shapeScall;
    var result = Math.min(x,y);
    return [result,result]
}
 
//common
function ParsentCalculation(base,target){
    var result = base/100*target;
    return result;
}
 
function checkalert(str){
    var flag = false;
    if (flag == true){
        $.writeln(str)
    }
}
 
 
 
function createFolder(){
    userFolder =app.project.items.addFolder(useredittext.text);
    headerFolder = app.project.items.addFolder("header");
    headerFolder.parentFolder = userFolder;
    compFolder = app.project.items.addFolder("Comp");
    compFolder.parentFolder = userFolder;
}

```