中文字幕二区_国产精品免费在线观看_黄色网站观看_人人草人人澡_日本真实娇小xxxx

您的位置: 首頁(yè) > 技術(shù)文檔 > 圖形圖像 > 批量更改圖片尺寸的ps腳本
圖層高級(jí)混合 【基礎(chǔ)教程】 回到列表 超酷的金色組合
 批量更改圖片尺寸的ps腳本

作者:xiexienile 時(shí)間: 2008-10-08 文檔類(lèi)型:原創(chuàng) 來(lái)自:藍(lán)色理想

第 1 頁(yè) 批量更改圖片尺寸的ps腳本
第 2 頁(yè) 批量更改圖片尺寸的ps腳本—代碼[1]
第 3 頁(yè) 批量更改圖片尺寸的ps腳本—代碼[2]

function shui(){ //水印處理函數(shù)
    if (!win.group.shuiSet.other.open.e.text) {
        alert("您沒(méi)有選擇水印文件");
    }else{
            var shuiFlie = File(win.group.shuiSet.other.open.e.text);
            docShui= open(shuiFlie);
            docShui.changeMode(ChangeMode.RGB);
            if (docShui.layers.length>1) docShui.mergeVisibleLayers(); //合并可見(jiàn)層
            var shuiLayer = docShui.activeLayer;
            
            if (parseInt(shuiLayer.bounds.toString().replace(/\D/g,"")) == 0) {
                docShui.close(SaveOptions.DONOTSAVECHANGES);
                if(confirm("水印文件內(nèi)容為空,繼續(xù)操作將不會(huì)添加任何水印")) go(false);//繼續(xù)操作,只是不添加水印        
            }else{
                //拷貝水印
                var suo=Number(win.group.shuiSet.other.hun.e.text);
                if (!suo) suo=1; //容錯(cuò)
                if (suo<0) suo=1;
                docShui.resizeImage(docShui.width*suo,docShui.height*suo,PRESOLUTION, ResampleMethod.BICUBIC); //變換水印大小
                var sW=Number(shuiLayer.bounds[2]-shuiLayer.bounds[0]);
                var sH=Number(shuiLayer.bounds[3]-shuiLayer.bounds[1]);
                docShui.selection.selectAll();
                docShui.selection.copy();
                docShui.close(SaveOptions.DONOTSAVECHANGES);                
                //新建文檔定義水印為圖案
                if (win.group.shui.g.fill.value){
                    var newDR = app.documents.add(Number(win.group.shuiSet.other.dis.e1.text)+sW, Number(win.group.shuiSet.other.dis.e2.text)+sH, 72, "ShuiTu", NewDocumentMode.RGB, DocumentFill.TRANSPARENT);
                    newDR.paste();
                    newDR.selection.selectAll();
                    setPattern("BlueIdea-Script-Watermark-"+nowTime.toString());
                    newDR.close(SaveOptions.DONOTSAVECHANGES);                    
                    newDR= null;
                    }
                go(true,sW,sH);
            }
    }
}
function pasteShui(nWidth,nHeight,moveX,moveY,sW,sH,sHun){ //粘貼水印及偏移or 填充
    app.activeDocument.changeMode(ChangeMode.RGB);
    if(win.group.shui.g.one.value){
                switch (true) {
                    case (allp.po1.c1.value||allp.po2.c4.value||allp.po3.c7.value):
                        NowMX=moveX-nWidth/2+sW/2;
                        break;
                    case (allp.po1.c2.value||allp.po2.c5.value||allp.po3.c8.value):
                        NowMX=moveX;
                        break;
                    case (allp.po1.c3.value||allp.po2.c6.value||allp.po3.c9.value):
                        NowMX=nWidth/2-moveX-sW/2;
                        break;
                    default :
                        NowMX=0;
                }
                switch (true) {
                    case (allp.po1.c1.value||allp.po1.c2.value||allp.po1.c3.value):
                        NowMY=moveY-nHeight/2+sH/2;
                        break;
                    case (allp.po2.c4.value||allp.po2.c5.value||allp.po2.c6.value):
                        NowMY=moveY;
                        break;
                    case (allp.po3.c7.value||allp.po3.c8.value||allp.po3.c9.value):
                        NowMY=nHeight/2-moveY-sH/2;
                        break;
                    default :
                        NowMY=0;
                }                 
                app.activeDocument.paste();
                app.activeDocument.activeLayer.translate (NowMX,NowMY);
    }else{
            app.activeDocument.artLayers.add();
            app.activeDocument.selection.selectAll();
            fillPattern("BlueIdea-Script-Watermark-"+nowTime.toString(),"id",100);
    }
    app.activeDocument.activeLayer.blendMode =eval("BlendMode."+sHun);
}
function save(docRef) {    //儲(chǔ)存函數(shù)
        if (win.group.other.c.value){ //判斷是否另存
            var don=win.group.otherSet.Quality;
            var inEmbedICC=win.group.otherSet.icc.value;
            var saveOptions;
            switch (saveType) {
                case "jpeg" :
                            docRef.flatten() ;//合并圖層,以儲(chǔ)存jpg                            
                            docRef.changeMode(ChangeMode.RGB); // 更改為rgb模式,避免其它模式無(wú)法儲(chǔ)存
                            docRef.bitsPerChannel = BitsPerChannelType.EIGHT;
                            saveOptions = new JPEGSaveOptions();
                            saveOptions.quality = don.d.selection.index; //獲取壓縮質(zhì)量
                            if (don.c.value) {
                                docRef.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true);
                                }
                            saveOptions.embedColorProfile = inEmbedICC;
                            var typeName="jpg"; //定義后綴
                            break;
                case "gif" :
                            if (docRef.artLayers.length>1)docRef.mergeVisibleLayers(); //合并可見(jiàn)層
                            docRef.changeMode(ChangeMode.RGB);
                            saveOptions = new GIFSaveOptions();
                            saveOptions.colors = Math.pow(2,don.d.selection.index+1);
                            if (don.c.value){
                                saveOptions.dither = Dither.DIFFUSION; //擴(kuò)散仿色        
                                }else{
                                saveOptions.dither = Dither.NONE;    
                                } ;
                            if (don.c2.value) {
                                saveOptions.transparency=1;
                                }else{
                                saveOptions.transparency=0;
                                };
                            //saveOptions.matte = MatteType.NONE; //雜邊無(wú),否則為白色
                            saveOptions.interlaced = 0; //不交錯(cuò)
                            var typeName="gif";
                            break;
                case "psd" :
                            saveOptions = new PhotoshopSaveOptions();
                            saveOptions.embedColorProfile = inEmbedICC;                            
                            var typeName="psd";
                            break;
                case "tiff" :
                            docRef.flatten() ;    
                            saveOptions = new TiffSaveOptions();
                            saveOptions.embedColorProfile = inEmbedICC;
                            if (don.c.value) {
                                saveOptions.imageCompression = TIFFEncoding.TIFFLZW;
                            } else {
                                saveOptions.imageCompression = TIFFEncoding.NONE;
                            }
                            var typeName="tif";    
                            break;
                default :
                            alert ("-_-!!! SaveType");
                }
            
                // 獲取另存文件夾及前后追加字段
                var headWord = win.group.otherSet.head.e.text;
                var footWord = win.group.otherSet.foot.e.text;    
                
                if (win.group.otherSet.otherF.c.value){ //如果選中另存至文件夾
                            if (win.group.otherSet.folderS.s.text){
                                var saveFolder = win.group.otherSet.folderS.s.text+"/";    
                            }else{    
                                var saveFolder = docRef.path+"/newsize_";  //容錯(cuò),避免沒(méi)有具體選擇另存到那個(gè)文件夾
                            }
                }else{
                            if (headWord || footWord){
                                var saveFolder = docRef.path+"/";
                            }else{
                                var saveFolder = docRef.path+"/newsize_"; //容錯(cuò),避免沒(méi)有添加前后綴而保存在本文件夾
                            }
                }
                if (docRef.name.lastIndexOf('.')==-1){  //根據(jù)原文件名有否后綴,判斷是否去掉后綴
                        var oldname=docRef.name;
                    }else{
                        var oldname=docRef.name.substring(0,docRef.name.lastIndexOf('.'));
                    }
                
            docRef.saveAs(new File(saveFolder + headWord + oldname + footWord + "."+ typeName),saveOptions, true,Extension.LOWERCASE);    //設(shè)定輸出文件名稱            
        }else{
            docRef.save();
        }
        docRef.close(SaveOptions.DONOTSAVECHANGES); //關(guān)閉當(dāng)前文檔    
}
function go(shuiOK,sW,sH) { //最后循環(huán)處理及關(guān)閉
        var x=Number(win.group.corrdination.x.e.text);
        var y=Number(win.group.corrdination.y.e.text);
        var a=win.group.a.c.value;
        var b=win.group.b.c.value; //選中則不顛倒橫豎,以輸入值為準(zhǔn)    
    
        if (saveType=="psd"){ //變更首選項(xiàng)
        var rememberMaximize = app.preferences.maximizeCompatibility; //psd格式最大兼容 原始選項(xiàng) --記錄
        var needMaximize = win.group.otherSet.Quality.c.value? QueryStateType.ALWAYS : QueryStateType.NEVER;
            if ( app.preferences.maximizeCompatibility != needMaximize ) {
                        app.preferences.maximizeCompatibility = needMaximize;
                }
        }        
        
        if (shuiOK){ //獲取水印偏移量及混合模式
        var mdis =win.group.shuiSet.other.dis;
        var moveX=Number(mdis.e1.text),moveY=Number(mdis.e2.text);
            for (i=0;i<23;i++) {
                if (win.group.shuiSet.other.hun.d.items[i].selected==true){
                    var sHun=sBlend[i].substring(sBlend[i].indexOf(",")+1);
                    break;
                    }
            }
        }
        
        if (!win.group.now.c.value) {  // 當(dāng)前活動(dòng)文檔為操作對(duì)象    
                var k=100/app.documents.length; //定義每個(gè)文件所占進(jìn)度比例
                while (app.documents.length){
                        var docRef = app.activeDocument;
                        newsize(docRef,a,b,x,y);
                        if(shuiOK) pasteShui(Number(docRef.width),Number(docRef.height),moveX,moveY,sW,sH,sHun);
                        save(docRef);
                        win.group.timeline.value =win.group.timeline.value+k;
                }
        }else{ // 文件夾為操作對(duì)象            
                var openFolder = Folder(win.group.folderO.s.text);                
                var fileList = openFolder.getFiles() //獲取open文件夾下所有文件
                var k=100/fileList.length;
                for (i=0;i<fileList.length;i++){
                    if (fileList[i] instanceof File && fileList[i].hidden == false){ //不處理隱藏文件
                        open(fileList[i]);
                        var docRef = app.activeDocument;
                        newsize(docRef,a,b,x,y);
                        if(shuiOK) pasteShui(Number(docRef.width),Number(docRef.height),moveX,moveY,sW,sH,sHun);
                        save(docRef);
                    }
                    win.group.timeline.value =win.group.timeline.value+k;
                }
        }
    
    if ( rememberMaximize != undefined )  app.preferences.maximizeCompatibility = rememberMaximize;  //psd格式最大兼容選項(xiàng)還原
    app.preferences.rulerUnits = startRulerUnits;
    app.preferences.typeUnits = startTypeUnits;
    if (shuiOK && win.group.shui.g.fill.value) delPattern(); //清除圖案定義
    this.parent.parent.close();
}
win.buttons.Btnok.onClick = function () {    
        if (win.group.shui.c.value) {
            shui(); //處理水印及最后完成
        }else{
            go(false);
        }
}
win.center();
win.show();

 

本文鏈接:http://www.95time.cn/tech/graph/2008/6216.asp 

出處:藍(lán)色理想
責(zé)任編輯:bluehearts

上一頁(yè) 批量更改圖片尺寸的ps腳本—代碼[1] 下一頁(yè)

◎進(jìn)入論壇Photoshop、Fireworks版塊參加討論,我還想發(fā)表評(píng)論

相關(guān)文章
批量更改圖片尺寸的ps腳本
關(guān)鍵字搜索 常規(guī)搜索 推薦文檔
熱門(mén)搜索:CSS Fireworks 設(shè)計(jì)比賽 網(wǎng)頁(yè)制作 web標(biāo)準(zhǔn) 用戶體驗(yàn) UE photoshop Dreamweaver Studio8 Flash 手繪 CG
站點(diǎn)最新 站點(diǎn)最新列表
周大福“敬•自然”設(shè)計(jì)大賽開(kāi)啟
國(guó)際體驗(yàn)設(shè)計(jì)大會(huì)7月將在京舉行
中國(guó)國(guó)防科技信息中心標(biāo)志征集
云計(jì)算如何讓安全問(wèn)題可控
云計(jì)算是多數(shù)企業(yè)唯一擁抱互聯(lián)網(wǎng)的機(jī)會(huì)
阿里行云
云手機(jī)年終巨獻(xiàn),送禮標(biāo)配299起
阿里巴巴CTO王堅(jiān)的"云和互聯(lián)網(wǎng)觀"
1499元買(mǎi)真八核 云OS雙蛋大促
首屆COCO桌面手機(jī)主題設(shè)計(jì)大賽
欄目最新 欄目最新列表
淺談JavaScript編程語(yǔ)言的編碼規(guī)范
如何在illustrator中繪制臺(tái)歷
Ps簡(jiǎn)單繪制一個(gè)可愛(ài)的鉛筆圖標(biāo)
數(shù)據(jù)同步算法研究
用ps作簡(jiǎn)單的作品展示頁(yè)面
CSS定位機(jī)制之一:普通流
25個(gè)最佳最閃亮的Eclipse開(kāi)發(fā)項(xiàng)目
Illustrator中制作針線縫制文字效果
Photoshop制作印刷凹凸字體
VS2010中創(chuàng)建自定義SQL Rule
>> 分頁(yè) 首頁(yè) 前頁(yè) 后頁(yè) 尾頁(yè) 頁(yè)次:3/3頁(yè) 1個(gè)記錄/頁(yè) 轉(zhuǎn)到 頁(yè) 共3個(gè)記錄

藍(lán)色理想版權(quán)申明:除部分特別聲明不要轉(zhuǎn)載,或者授權(quán)我站獨(dú)家播發(fā)的文章外,大家可以自由轉(zhuǎn)載我站點(diǎn)的原創(chuàng)文章,但原作者和來(lái)自我站的鏈接必須保留(非我站原創(chuàng)的,按照原來(lái)自一節(jié),自行鏈接)。文章版權(quán)歸我站和作者共有。

轉(zhuǎn)載要求:轉(zhuǎn)載之圖片、文件,鏈接請(qǐng)不要盜鏈到本站,且不準(zhǔn)打上各自站點(diǎn)的水印,亦不能抹去我站點(diǎn)水印。

特別注意:本站所提供的攝影照片,插畫(huà),設(shè)計(jì)作品,如需使用,請(qǐng)與原作者聯(lián)系,版權(quán)歸原作者所有,文章若有侵犯作者版權(quán),請(qǐng)與我們聯(lián)系,我們將立即刪除修改。

您的評(píng)論
用戶名:  口令:
說(shuō)明:輸入正確的用戶名和密碼才能參與評(píng)論。如果您不是本站會(huì)員,你可以注冊(cè) 為本站會(huì)員。
注意:文章中的鏈接、內(nèi)容等需要修改的錯(cuò)誤,請(qǐng)用報(bào)告錯(cuò)誤,以利文檔及時(shí)修改。
不評(píng)分 1 2 3 4 5
注意:請(qǐng)不要在評(píng)論中含與內(nèi)容無(wú)關(guān)的廣告鏈接,違者封ID
請(qǐng)您注意:
·不良評(píng)論請(qǐng)用報(bào)告管理員,以利管理員及時(shí)刪除。
·尊重網(wǎng)上道德,遵守中華人民共和國(guó)的各項(xiàng)有關(guān)法律法規(guī)
·承擔(dān)一切因您的行為而直接或間接導(dǎo)致的民事或刑事法律責(zé)任
·本站評(píng)論管理人員有權(quán)保留或刪除其管轄評(píng)論中的任意內(nèi)容
·您在本站發(fā)表的作品,本站有權(quán)在網(wǎng)站內(nèi)轉(zhuǎn)載或引用
·參與本評(píng)論即表明您已經(jīng)閱讀并接受上述條款
推薦文檔 | 打印文檔 | 評(píng)論文檔 | 報(bào)告錯(cuò)誤  
專(zhuān)業(yè)書(shū)推薦 更多內(nèi)容
網(wǎng)站可用性測(cè)試及優(yōu)化指南
《寫(xiě)給大家看的色彩書(shū)1》
《跟我去香港》
眾妙之門(mén)—網(wǎng)站UI 設(shè)計(jì)之道
《Flex 4.0 RIA開(kāi)發(fā)寶典》
《贏在設(shè)計(jì)》
犀利開(kāi)發(fā)—jQuery內(nèi)核詳解與實(shí)踐
作品集 更多內(nèi)容

雜⑦雜⑧ Gold NORMANA V2