论坛帮助 |
社区圈子 |
日历事件 |
2023-02-11, 08:38 | 只看该作者 #3 | ||
|
|||
正式会员
等级: 一袋长老
|
在网上看到一个自动识别人脸的P图脚本,但是代码看得不太明白,应该在这个基础上修改一下就可以实现。具体代码如下:
#target "photoshop" //var outputWidth = 1024; var inputFolder = Folder.selectDialog("Input folder"); var outputFolder = Folder.selectDialog("Output folder"); if (inputFolder != null && outputFolder != null) { var files = inputFolder.getFiles("*.jpg"); if (files.length== 0) { alert(" no face pic."); } for (var i = 0; i < files.length; i++) { var file = files[i]; var doc = app.open(file); // if (doc.width > outputWidth) { // var height = (doc.height / doc.width) * outputWidth; // doc.resizeImage(outputWidth + "px", height + "px"); // } if (doc.width > 0) { var param_leftEyeSize = Math.random()*2 - 1; var param_rightEyeSize = Math.random()*2 - 1; var param_leftEyeHeight = Math.random()*2 - 1; var param_rightEyeHeight = Math.random()*2 - 1; var param_leftEyeWidth = Math.random()*2 - 1; var param_rightEyeWidth = Math.random()*2 - 1; var param_leftEyeTilt = Math.random()*2 - 1; var param_rightEyeTilt = Math.random()*2 - 1; var param_eyeDistance = Math.random()*2 - 1; var param_smile = Math.random()*2 - 1; var param_upperLip = Math.random()*2 - 1; var param_lowerLip = Math.random()*2 - 1; var param_mouthWidth = Math.random()*2 - 1; var param_noseWidth = Math.random()*2 - 1; var param_faceWidth = Math.random()*2 - 1; var param_chinHeight = Math.random()*2 - 1; var param_jawShape = Math.random()*2 - 1; var param_mouthHeight = Math.random()*2 - 1; var param_noseHeight = Math.random()*2 - 1; var param_foreheadHeight = Math.random()*2 - 1; var idLqFy = charIDToTypeID( "LqFy" ); var desc16 = new ActionDescriptor(); var idLqMe = charIDToTypeID( "LqMe" ); var idfaceMesh = stringIDToTypeID( "faceMesh" ); var desc17 = new ActionDescriptor(); var idfaceDescriptorVersion = stringIDToTypeID( "faceDescriptorVersion" ); desc17.putInteger( idfaceDescriptorVersion, 2 ); var idfaceMeshVersion = stringIDToTypeID( "faceMeshVersion" ); desc17.putInteger( idfaceMeshVersion, 2 ); var idfaceInfoList = stringIDToTypeID( "faceInfoList" ); var list1 = new ActionList(); var desc18 = new ActionDescriptor(); var idfeatureValues = stringIDToTypeID( "featureValues" ); var desc20 = new ActionDescriptor(); var idleftEyeSize = stringIDToTypeID( "leftEyeSize" ); desc20.putDouble( idleftEyeSize, param_leftEyeSize ); var idrightEyeSize = stringIDToTypeID( "rightEyeSize" ); desc20.putDouble( idrightEyeSize, param_rightEyeSize ); var idleftEyeHeight = stringIDToTypeID( "leftEyeHeight" ); desc20.putDouble( idleftEyeHeight, param_leftEyeHeight ); var idrightEyeHeight = stringIDToTypeID( "rightEyeHeight" ); desc20.putDouble( idrightEyeHeight, param_rightEyeHeight ); var idleftEyeWidth = stringIDToTypeID( "leftEyeWidth" ); desc20.putDouble( idleftEyeWidth, param_leftEyeWidth ); var idrightEyeWidth = stringIDToTypeID( "rightEyeWidth" ); desc20.putDouble( idrightEyeWidth, param_rightEyeWidth ); var idleftEyeTilt = stringIDToTypeID( "leftEyeTilt" ); desc20.putDouble( idleftEyeTilt, param_leftEyeTilt ); var idrightEyeTilt = stringIDToTypeID( "rightEyeTilt" ); desc20.putDouble( idrightEyeTilt, param_rightEyeTilt ); var ideyeDistance = stringIDToTypeID( "eyeDistance" ); desc20.putDouble( ideyeDistance, param_eyeDistance ); var idsmile = stringIDToTypeID( "smile" ); desc20.putDouble( idsmile, param_smile ); var idupperLip = stringIDToTypeID( "upperLip" ); desc20.putDouble( idupperLip, param_upperLip ); var idlowerLip = stringIDToTypeID( "lowerLip" ); desc20.putDouble( idlowerLip, param_lowerLip ); var idmouthWidth = stringIDToTypeID( "mouthWidth" ); desc20.putDouble( idmouthWidth, param_mouthWidth ); var idnoseWidth = stringIDToTypeID( "noseWidth" ); desc20.putDouble( idnoseWidth, param_noseWidth ); var idfaceWidth = stringIDToTypeID( "faceWidth" ); desc20.putDouble( idfaceWidth, param_faceWidth ); var idchinHeight = stringIDToTypeID( "chinHeight" ); desc20.putDouble( idchinHeight, param_chinHeight ); var idjawShape = stringIDToTypeID( "jawShape" ); desc20.putDouble( idjawShape, param_jawShape ); var idmouthHeight = stringIDToTypeID( "mouthHeight" ); desc20.putDouble( idmouthHeight, param_mouthHeight ); var idnoseHeight = stringIDToTypeID( "noseHeight" ); desc20.putDouble( idnoseHeight, param_noseHeight ); var idforeheadHeight = stringIDToTypeID( "foreheadHeight" ); desc20.putDouble( idforeheadHeight, param_foreheadHeight ); desc18.putObject( idfeatureValues, idfeatureValues, desc20 ); var idfeatureDisplacements = stringIDToTypeID( "featureDisplacements" ); var desc21 = new ActionDescriptor(); var idfeatureDisplacements = stringIDToTypeID( "featureDisplacements" ); desc18.putObject( idfeatureDisplacements, idfeatureDisplacements, desc21 ); var idfaceInfo = stringIDToTypeID( "faceInfo" ); list1.putObject( idfaceInfo, desc18 ); desc17.putList( idfaceInfoList, list1 ); var idfaceMesh = stringIDToTypeID( "faceMesh" ); desc16.putObject( idfaceMesh, idfaceMesh, desc17 ); executeAction( idLqFy, desc16, DialogModes.NO ); } var options = new ExportOptionsSaveForWeb(); // options.format = SaveDocumentType.PNG; // options.PNG8 = false; options.format = SaveDocumentType.PNG; options.PNG8 = false; doc.exportDocument(outputFolder, ExportType.SAVEFORWEB, options); doc.close(SaveOptions.DONOTSAVECHANGES); $.writeln('File ' + (i + 1) + ' of ' + files.length + ' processed'); } } 此帖于 2023-02-11 08:39 被 zxmflying 编辑. 原因: 代码排版凌乱 |
||