|
以下是經過DeepSeek全面修正的Photoshop人像修圖腳本: ![]() javascript 復制 // Photoshop人像精修腳本// 版本:3.1// 最后更新:2024-02-25// 功能:自動磨皮 + 清晰化處理 + 智能蒙版// 注意:適用于Photoshop CC 2018及以上版本// 主程序入口functionmain(){ if(!documents.length){ alert('請先打開要處理的圖像'); return; } var doc = app.activeDocument; var originalLayer = doc.activeLayer; var savedState = doc.activeHistoryState; try{ // ====================== // 創(chuàng)建修圖組 // ====================== var retouchGroup = doc.layerSets.add(); retouchGroup.name ='AI_Retouch_v3'; // ====================== // 頻率分離處理 // ====================== // 低頻層(顏色/紋理) var lowFreqLayer = originalLayer.duplicate(retouchGroup, ElementPlacement.PLACEATBEGINNING); lowFreqLayer.name ='低頻層'; activateLayer(lowFreqLayer); applySurfaceBlur(15,15); // 高頻層(細節(jié)) var highFreqLayer = originalLayer.duplicate(retouchGroup, ElementPlacement.PLACEATBEGINNING); highFreqLayer.name ='高頻層'; activateLayer(highFreqLayer); applyHighPass(5); highFreqLayer.blendMode = BlendMode.LINEARLIGHT; // ====================== // 智能磨皮處理 // ====================== var smoothLayer = originalLayer.duplicate(retouchGroup, ElementPlacement.PLACEATBEGINNING); smoothLayer.name ='智能磨皮'; activateLayer(smoothLayer); applySurfaceBlur(25,25); // 創(chuàng)建保護蒙版 createProtectionMask(smoothLayer); // ====================== // 細節(jié)增強處理 // ====================== var sharpLayer = originalLayer.duplicate(retouchGroup, ElementPlacement.PLACEATBEGINNING); sharpLayer.name ='細節(jié)增強'; activateLayer(sharpLayer); applyUnSharpMask(150,1.5,0); sharpLayer.blendMode = BlendMode.LUMINOSITY; sharpLayer.opacity =70; // ====================== // 智能調色處理 // ====================== createCurvesAdjustment(); // ====================== // 最終整理 // ====================== retouchGroup.visible =true; originalLayer.visible =false; alert('處理完成!\n建議操作:\n1. 調整各圖層透明度\n2. 優(yōu)化蒙版邊緣\n3. 檢查局部細節(jié)'); }catch(e){ doc.activeHistoryState = savedState; alert('處理出錯: '+ e); }}// ======================// 核心功能函數(shù)// ======================// 激活指定圖層functionactivateLayer(layer){ app.activeDocument.activeLayer = layer;}// 應用表面模糊functionapplySurfaceBlur(radius, threshold){ var desc =newActionDescriptor(); desc.putUnitDouble(charIDToTypeID('Rds '),charIDToTypeID('#Pxl'), radius); desc.putUnitDouble(charIDToTypeID('Thsh'),charIDToTypeID('#Pxl'), threshold); executeAction(charIDToTypeID('SfBl'), desc, DialogModes.NO);}// 應用高反差保留functionapplyHighPass(radius){ var desc =newActionDescriptor(); desc.putUnitDouble(charIDToTypeID('Rds '),charIDToTypeID('#Pxl'), radius); executeAction(charIDToTypeID('HghP'), desc, DialogModes.NO);}// 應用USM銳化functionapplyUnSharpMask(amount, radius, threshold){ var desc =newActionDescriptor(); desc.putUnitDouble(charIDToTypeID('Amnt'),charIDToTypeID('#Prc'), amount); desc.putUnitDouble(charIDToTypeID('Rds '),charIDToTypeID('#Pxl'), radius); desc.putUnitDouble(charIDToTypeID('Thsh'),charIDToTypeID('#Pxl'), threshold); executeAction(charIDToTypeID('USM '), desc, DialogModes.NO);}// 創(chuàng)建保護蒙版functioncreateProtectionMask(layer){ layer.layerMaskEnabled =true; var mask = layer.layerMask; // 使用自動蒙版算法 var desc =newActionDescriptor(); var ref =newActionReference(); ref.putEnumerated(charIDToTypeID('Chnl'),charIDToTypeID('Chnl'),charIDToTypeID('Msk ')); desc.putReference(charIDToTypeID('null'), ref); desc.putEnumerated(charIDToTypeID('T '),charIDToTypeID('BlcM'),charIDToTypeID('Abtc')); executeAction(charIDToTypeID('Ddls'), desc, DialogModes.NO);}// 創(chuàng)建曲線調整層functioncreateCurvesAdjustment(){ var desc =newActionDescriptor(); var list =newActionList(); // 創(chuàng)建S曲線 addCurvePoint(list,0,0); addCurvePoint(list,128,100); addCurvePoint(list,255,255); desc.putList(charIDToTypeID('Crv '), list); executeAction(charIDToTypeID('Crvs'), desc, DialogModes.NO);}// 添加曲線控制點functionaddCurvePoint(list, input, output){ var subList =newActionList(); subList.putInteger(input); subList.putInteger(output); list.putList(subList);}// 啟動腳本main(); 主要改進說明:
javascript 復制 // 磨皮強度調節(jié)點(第46行)applySurfaceBlur(25, 25); // 參數(shù)格式:(半徑, 閾值)// 銳化參數(shù)調節(jié)點(第57行)applyUnSharpMask(150, 1.5, 0); // 參數(shù)格式:(強度%, 半徑, 閾值)// 曲線調整參數(shù)(第89-91行)addCurvePoint(list, 0, 0); // 陰影點addCurvePoint(list, 128, 100); // 中間調addCurvePoint(list, 255, 255); // 高光 ![]() 使用說明:
技術亮點:
常見問題處理:
|
|
|