第二个PS脚本-添加各种文字水印

902 0

通过被人代码改的:


color = [255, 0, 0] 
shuiyin("xujoe", 10, 60, null, color, 50);

function shuiyin(Word, x, y, WordSize, color, valOpacite) {
/*
默认值:
文字: Word=“xujoe”;中文乱码
位置:x=0;y=0;(图片比例,值:0-100)
大小WordSize=20
颜色color=[0,0,0];黑色(值:[0-255,0-255,0-255])
透明度:valOpacite=100(值:0-100)
原始代码出处:https://www.ps-scripts.com/viewtopic.php?f=67&t=24519&p=152937&hilit=watermark#p152937
    
*/

        var Word = arguments[0] ? arguments[0] : "xujoe";
        var x = arguments[1] ? arguments[1] : 0;
        var y = arguments[2] ? arguments[2] : 0;
        var WordSize = arguments[3] ? arguments[3] : 20;
        var color = arguments[4] ? arguments[4] : [0, 0, 0];
        var valOpacite = arguments[5] ? arguments[5] : 100;
        var valOpacite = 50;

        var TextColor = new SolidColor;
        TextColor.rgb.red = color[0];
        TextColor.rgb.green = color[1];
        TextColor.rgb.blue = color[2];
        TextColor.opacity = valOpacite;

        var docRef = activeDocument;
        /*****看不懂不知道啥用处
var docResolution = app.activeDocument.resolution;
$.writeln (docResolution);
app.activeDocument.resizeImage( undefined, undefined, 72, ResampleMethod.NONE);
*/
        /*
var Rouge = color[0]; //valeurs de 0 a 255
var Vert = color[1];//RGB颜色
var Bleu = color[2];
*/
        valOpacite = 100; //de 0 a 100% //透明度
        //Opacite = 85 ; //调整文本的透明度(从0到100) 
        //应该是字体吧
        NomPolice = "CourierNewPS-BoldMT"; // "ArialMT" "LucidaCalligraphy-Italic"  
        //这两个决定位置posHoriz,posVertic
        var posHoriz = docRef.width * (x / 100);  
        var posVertic = docRef.height * (y / 100); //pour la position du texte 
        /*这里把RGB颜色转为16进制颜色
var textColor = new SolidColor;
textColor.rgb.red = Rouge;
textColor.rgb.green = Vert;
textColor.rgb.blue = Bleu;
textColor.opacity = valOpacite; 
*/

        //alert( TailleFonte ) 
        //fontPostScriptName = "ArialMT"; //"LucidaCalligraphy-Italic"
        //"ParkAvenueBT-Regular" - Normal Gras ...etc 
        //app.displayDialogs = DialogModes.NO;
        //app.preferences.typeUnits = TypeUnits.POINTS; 
        var newTextLayer = docRef.artLayers.add(); // le calque de Texte//文本跟踪
        newTextLayer.kind = LayerKind.TEXT;
        newTextLayer.textItem.contents = Word;
        newTextLayer.textItem.position = Array(posHoriz, posVertic);
        //newTextLayer.textItem.postScriptName = fontPostScriptName;
        newTextLayer.textItem.font = NomPolice;
        newTextLayer.textItem.size = WordSize;
        newTextLayer.textItem.color = TextColor; //textColor;
        newTextLayer.opacity = valOpacite;;
        docRef.flatten(); //aplatir  
}


发表回复