├── BBCodeParser.js ├── README.md ├── addLayers.jsx ├── au3 ├── PSD2JPG.au3 ├── addLayers.au3 ├── addLayers4PSD.au3 ├── readFont.au3 ├── readTextLayers.au3 └── test.au3 ├── psd2jpg.jsx ├── readFont.jsx └── readTextLayers.jsx /BBCodeParser.js: -------------------------------------------------------------------------------- 1 | var supportedBBCodes = ["b","color","i","fi","fb","fontname","fontsize"]; 2 | /* 3 | * Parse BBCode. Example: [b][i]Bold Italic[/i][/b] example. -> [{text:"Bold Italic",bold:true,italic:false}, {text: "example."}] 4 | */ 5 | function parseBBCode(text){ 6 | var run = {}; 7 | run.text = text; 8 | var valid = validBBCode(text); 9 | if (valid) { 10 | return parseRun(run); 11 | }else{ 12 | return [run]; 13 | } 14 | } 15 | 16 | function parseRun(run){ 17 | var runs = []; 18 | if (run.text === "") { 19 | return runs; 20 | } 21 | var str = run.text; 22 | var plainText = ""; 23 | for (var index = 0; index <= str.length - 1; index++) { 24 | if (currentChar(str,index) === "[") { 25 | var tagContent = textUntil("]",str,index); 26 | var codeName = getBBCodeName(tagContent); 27 | if (codeName != "" && tagContent.indexOf("/") === -1){ 28 | var text = plainText; 29 | if (text != "") { 30 | runs.push(createRun(text,run,"","")) 31 | } 32 | plainText = ""; 33 | var endTag = "[/"+codeName+"]" 34 | var runText = textUntil(endTag,str,index) 35 | if (runText != "") { 36 | index = index + runText.length - 1 37 | runText = codePairStripped(runText,tagContent,endTag) 38 | var richRun = createRun(runText,run,codeName,tagContent) 39 | var innerRuns = []; 40 | parseInnerRuns(richRun,innerRuns) 41 | runs = runs.concat(innerRuns); 42 | } 43 | } 44 | }else { 45 | plainText = plainText + (currentChar(str,index)); 46 | } 47 | 48 | 49 | } 50 | if (plainText != "") { 51 | runs.push(createRun(plainText,run,"","")) 52 | } 53 | return runs; 54 | } 55 | 56 | function parseInnerRuns(run,runs) { 57 | var parsedRuns = parseRun(run); 58 | if (parsedRuns.length === 1) {// no tags 59 | runs.push(parsedRuns[0]); 60 | }else{ 61 | for (var index = 0; index < parsedRuns.length; index++) { 62 | var innerRun = parsedRuns[index]; 63 | parseInnerRuns(innerRun,runs) 64 | } 65 | } 66 | } 67 | 68 | /* 69 | * text:[color=#ff00ff]Red[/color],codeName:color,tagContent:[color=#ff00ff] 70 | */ 71 | function createRun(text,parentRun,codeName,tagContent){ 72 | var run = {}; 73 | run.text = text 74 | if (parentRun) { 75 | run.bold = parentRun.bold; 76 | run.italic = parentRun.italic; 77 | run.color = parentRun.color; 78 | run.fontname = parentRun.fontname; 79 | run.fontsize = parentRun.fontsize; 80 | run.fauxBold = parentRun.fauxBold; 81 | run.fauxItalic = parentRun.fauxItalic; 82 | } 83 | 84 | codeName = codeName.toLowerCase(); 85 | 86 | if (codeName === "b") { 87 | run.bold = true; 88 | }else if (codeName === "i") { 89 | run.italic = true; 90 | }else if (codeName === "fb") { 91 | run.fauxBold = true; 92 | }else if (codeName === "fi"){ 93 | run.fauxItalic = true; 94 | }else if (codeName === "fontname"){ 95 | run.fontname = parseFontName(tagContent); 96 | }else if (codeName === "fontsize"){ 97 | run.fontsize = parseFontSize(tagContent); 98 | }else if (codeName === "color") { 99 | run.color = parseColor(tagContent) 100 | } 101 | return run; 102 | } 103 | 104 | /* 105 | * parse [fontname=Tahoma] and return Tahoma 106 | */ 107 | function parseFontName(tagContent) { 108 | try { 109 | var name = tagContent.substring(tagContent.indexOf("=")+1,tagContent.length-1); 110 | return name; 111 | } catch (error) { 112 | console.log(error); 113 | } 114 | return ""; 115 | } 116 | 117 | /* 118 | * parse [fontsize=11.0] and return 11.0 119 | */ 120 | function parseFontSize(tagContent){ 121 | try { 122 | var size = parseFloat(tagContent.substring(tagContent.indexOf("=")+1,tagContent.length-1)); 123 | return size; 124 | } catch (error) { 125 | console.log(error); 126 | } 127 | return undefined; 128 | } 129 | 130 | 131 | /* 132 | * parse [color=#ff0000] and return the rgb value {r:255.g:0,b:0) 133 | */ 134 | function parseColor(tagContent) { 135 | try { 136 | var hex = tagContent.substring(tagContent.indexOf("=")+1,tagContent.length-1).toLowerCase(); 137 | var r = eval("0x"+hex.substring(1,3)).toString(10); 138 | var g = eval("0x"+hex.substring(3,5)).toString(10); 139 | var b = eval("0x"+hex.substring(5,7)).toString(10); 140 | return {r:r,g:g,b:b}; 141 | } catch (error) { 142 | console.log(error); 143 | } 144 | return {r:0,g:0,b:0}; 145 | } 146 | 147 | /* 148 | * [b]Hello [i]world[/i][/b] -> Hello [i]world[/i] 149 | */ 150 | function codePairStripped(runText,tagContent,endTag) { 151 | runText = runText.replace(tagContent,"") 152 | runText = runText.replace(endTag,"") 153 | return runText; 154 | } 155 | 156 | function escaped(text) { 157 | text = text.replace("\[","\\["); 158 | text = text.replace("\]","\\]"); 159 | return text; 160 | } 161 | 162 | /* 163 | * textUntil("]","[tag]content[/tag]",0) => "[tag]" 164 | */ 165 | function textUntil(endStr,str,index){ 166 | var text = ""; 167 | var textLeft=str.substring(index,str.length); 168 | if (textLeft.indexOf(endStr)!=-1) { 169 | for (var i = index; i <= str.length - endStr.length; i++) { 170 | if (str.substring(i,i + endStr.length) === endStr) { 171 | text = text + endStr; 172 | break; 173 | }else{ 174 | var s = str.charAt(i); 175 | text = text + s; 176 | } 177 | } 178 | } 179 | return text; 180 | } 181 | 182 | function currentChar(str,index) { 183 | return str.charAt(index); 184 | } 185 | 186 | /* 187 | * [color=#ff0000] => color 188 | */ 189 | function getBBCodeName(str) { 190 | var regex = new RegExp("\\[/?(.*?)]"); 191 | var matchObject = regex.exec(str); 192 | if (matchObject) { 193 | var match = matchObject[1]; 194 | if (match.indexOf("=")!= -1) { 195 | match = match.substring(0,match.indexOf("=")); 196 | } 197 | if (isSupportedBBCode(match)) { 198 | return match; 199 | } 200 | } 201 | return ""; 202 | } 203 | 204 | function validBBCode(str) { 205 | var count = 0; 206 | var regex = new RegExp("\\[/?(.*?)]","g"); 207 | var matchObject = regex.exec(str); 208 | while (matchObject) { 209 | var match = matchObject[1]; 210 | if (match.indexOf("=") != -1) { 211 | match = match.substring(0,match.indexOf("=")); 212 | } 213 | if (match.indexOf("[") != -1 || match.indexOf("]") != -1) { 214 | return false; 215 | } 216 | if (isSupportedBBCode(match)) { 217 | count = count + 1; 218 | } 219 | matchObject = regex.exec(str); 220 | } 221 | if (count > 0) { 222 | if (count % 2 === 0) { 223 | return true; 224 | } 225 | } 226 | return false; 227 | } 228 | 229 | function isSupportedBBCode(code) { 230 | code = code.toLowerCase(); 231 | for (var index = 0; index < supportedBBCodes.length; index++) { 232 | var bbcode = supportedBBCodes[index]; 233 | if (code === bbcode) { 234 | return true; 235 | } 236 | } 237 | return false; 238 | } 239 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageTrans_PhotoshopScripts 2 | 3 | Photoshop JavaScript Files for ImageTrans 4 | 5 | * `addLayers.jsx`. Add text layers to an existing or a new PSD file. 6 | * `readFont.jsx`. Read the font name of the first text layer of an opened PSD file. 7 | * `readTextLayers.jsx`. Export the text layers into a txt file which can be imported into ImageTrans. 8 | * `psd2jpg.jsx`. Convert PSD files into JPG files. 9 | -------------------------------------------------------------------------------- /addLayers.jsx: -------------------------------------------------------------------------------- 1 | #include BBCodeParser.js 2 | var precisionMode=true; 3 | var richText=true; 4 | var psdExist=false; 5 | var addMask=false; 6 | var isPoint=false; 7 | var textKind=TextType.PARAGRAPHTEXT; 8 | var layerIsFound=false; 9 | var inputFolder = Folder.selectDialog("Select a folder to process"); 10 | var txtPath = inputFolder + "/" + "out.txt" 11 | var txtFile = new File(txtPath) 12 | if (txtFile.exists==false){ 13 | alert("out.txt does not exist!") 14 | } 15 | else{ 16 | app.preferences.rulerUnits=Units.PIXELS 17 | app.preferences.typeUnits=TypeUnits.POINTS 18 | app.displayDialogs=DialogModes.NO 19 | readParams(inputFolder.toString()) 20 | var matchedLayer; 21 | var b = new File(txtPath); 22 | b.open('r'); 23 | var previousFilename = ""; 24 | var previousPath = ""; 25 | var filepath = ""; 26 | var docRef; 27 | var index=0; 28 | while(!b.eof){ 29 | var line = b.readln(); 30 | //alert(line); 31 | var params = line.split(" "); 32 | var X=params[0]; 33 | var Y=params[1]; 34 | var width=params[2]; 35 | var height=params[3]; 36 | var filename = params[4]; 37 | filepath = inputFolder + "/" + filename ; 38 | filepath=changeToPSDPathIfExist(filepath) 39 | //alert(filepath); 40 | previousPath = inputFolder + "/" + previousFilename ; 41 | previousPath=changeToPSDPathIfExist(previousPath) 42 | var bgcolor=params[5]; 43 | var layername=params[6]; 44 | var pfontsize=12.0; 45 | pfontsize=params[7]; 46 | var lineheight=params[8]; 47 | var fontname=params[9]; 48 | var fontcolor=params[10]; 49 | var textDirection=params[11]; 50 | var alignment=params[12]; 51 | var wrap=true; 52 | if (params[13]=="false"){ 53 | wrap=false; 54 | } 55 | var bold=false; 56 | if (params[14]=="true"){ 57 | bold=true; 58 | } 59 | var italic=false; 60 | if (params[15]=="true"){ 61 | italic=true; 62 | } 63 | var capital=false; 64 | if (params[16]=="true"){ 65 | capital=true; 66 | } 67 | var rotationDegree=0; 68 | if (params[17]!="null"){ 69 | rotationDegree=params[17]; 70 | } 71 | var shadowRadius=1; 72 | if (params[18]!="null"){ 73 | shadowRadius=params[18]; 74 | } 75 | var shadowColor="null"; 76 | if (params[19]!="null"){ 77 | shadowColor=params[19]; 78 | } 79 | var text=params[params.length-1]; 80 | //alert(filepath); 81 | if (previousFilename!=filename){ 82 | if (previousFilename!=""){ 83 | SaveAsPSDandClose(docRef,previousPath) 84 | } 85 | previousFilename=filename 86 | //alert(filepath); 87 | var f = new File(filepath); 88 | docRef = open(f); 89 | index=0 90 | if (addMask==true && precisionMode==true){ 91 | addPreciseMask(filepath,docRef); 92 | } 93 | } 94 | index=index+1 95 | addMaskLayer(docRef,X,Y,width,height,bgcolor,index) 96 | addTextLayer(docRef,layername,X,Y,width,height,text,pfontsize,lineheight,fontname,fontcolor,textDirection,alignment,wrap,bold,italic,capital,rotationDegree,shadowRadius,shadowColor) 97 | } 98 | b.close(); 99 | SaveAsPSDandClose(docRef,filepath) 100 | } 101 | 102 | function addPreciseMask(filepath,docRef){ 103 | var maskPath = filepath+"-text-removed.jpg" 104 | var f = new File(maskPath); 105 | if (f.exists==false){ 106 | maskPath = filepath+"-text-removed.png" 107 | f = new File(maskPath); 108 | } 109 | if (f.exists==false){ 110 | return; 111 | } 112 | var maskDoc = open(f); 113 | var backLayer = maskDoc.artLayers[0]; 114 | backLayer.copy(); 115 | var bounds = backLayer.bounds; 116 | maskDoc.close(SaveOptions.DONOTSAVECHANGES); 117 | var targetLayer = docRef.paste(); 118 | //var targetBounds=targetLayer.Bounds 119 | //targetLayer.ApplyOffset(bounds[0]-targetBounds[0],bounds[1]-targetBounds[1],3) 120 | } 121 | 122 | function addTextLayer(docRef,layername,X,Y,width,height,text,pfontsize,lineheight,fontname,fontcolor,textDirection,alignment,wrap,bold,italic,capital,rotationDegree,shadowRadius,shadowColor){ 123 | var res=docRef.resolution; 124 | if (layername=="NotALayer"){ 125 | var textLayer = docRef.artLayers.add(); 126 | } 127 | else { 128 | layerIsFound=false; 129 | var textLayer = getMatchedTextLayer(docRef,layername); 130 | if (layerIsFound==false){ 131 | var textLayer = docRef.artLayers.add(); 132 | } 133 | } 134 | text=unescape(text) 135 | textLayer.kind=LayerKind.TEXT 136 | 137 | 138 | if (wrap==true){ 139 | textLayer.textItem.kind=TextType.PARAGRAPHTEXT 140 | width=width/res*72 141 | height=height/res*72 142 | textLayer.textItem.width=width 143 | textLayer.textItem.height=height 144 | }else{ 145 | textLayer.textItem.kind=TextType.POINTTEXT 146 | } 147 | 148 | 149 | if (bold==true){ 150 | textLayer.textItem.fauxBold=true; 151 | } 152 | if (italic==true){ 153 | textLayer.textItem.fauxItalic=true; 154 | } 155 | if (capital==true){ 156 | textLayer.textItem.capitalization=TextCase.ALLCAPS 157 | } 158 | if (rotationDegree!=0){ 159 | textLayer.rotate(rotationDegree,AnchorPosition.MIDDLECENTER) 160 | } 161 | 162 | var runs; 163 | if (richText==true) { 164 | runs = parseBBCode(text); 165 | text = ""; 166 | for (var index = 0; index <= runs.length - 1; index++) { 167 | text = text + runs[index].text; 168 | } 169 | } 170 | 171 | textLayer.textItem.position=Array(X,Y) 172 | textLayer.textItem.contents = text 173 | textLayer.textItem.direction = getDirection(textDirection) 174 | 175 | textLayer.textItem.size = new UnitValue(pfontsize/res*72,"px") 176 | textLayer.textItem.font = fontname 177 | textLayer.textItem.hyphenation = true 178 | textLayer.textItem.useAutoLeading = false 179 | textLayer.textItem.leading=textLayer.textItem.size*lineheight 180 | textLayer.textItem.color=getSolidColor(fontcolor) 181 | 182 | if (isPoint==true){ 183 | textLayer.textItem.kind=TextType.POINTTEXT 184 | var currentText=textLayer.textItem.contents; 185 | if (currentText.length 2 | Global $filename 3 | 4 | if $cmdLine[0]<>1 Then 5 | $filename="test.psd" 6 | ;Exit(1) 7 | Else 8 | $filename=$cmdLine[1] 9 | EndIf 10 | 11 | Export() 12 | 13 | Func Export() 14 | $app = ObjCreate("Photoshop.Application") 15 | $doc=$app.open(@WorkingDir& "\" &$filename) 16 | $purefileName=StringReplace($filename,".psd","",-1, $STR_NOCASESENSE) 17 | SaveAs($doc,@WorkingDir& "\" &$purefileName&".jpg") 18 | $doc.close(2) 19 | EndFunc 20 | 21 | Func SaveAs($doc,$path) 22 | Dim $ObjSaveOptions=ObjCreate("Photoshop.JPEGSaveOptions") 23 | ;if @error Then Exit 24 | With $ObjSaveOptions 25 | .EmbedColorProfile = True 26 | .FormatOptions = 1 27 | .Matte = 1 28 | .Quality = 12 29 | EndWith 30 | ConsoleWrite($path&@CRLF) 31 | $doc.SaveAS($path,$ObjSaveOptions,True,2) 32 | EndFunc -------------------------------------------------------------------------------- /au3/addLayers.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Global $FontSize = 6 5 | Global $TextItemWidth = 50 6 | Global $TextItemHeight = 50 7 | Global $Language = 1 8 | Global $addMask=1 9 | Global $precisionMode = 0 ;1 yes, 0 no 10 | Global $flip = 0 ;1 yes, 0 no 11 | Global $textKind = 2 ;1 point, 2 paragraph 12 | 13 | if $cmdLine[0]<>4 Then 14 | $addMask=1 ; 0 don't, 1 add. 15 | Else 16 | $addMask=$cmdLine[1] 17 | $precisionMode = $cmdLine[2] 18 | $flip = $cmdLine[3] 19 | $textKind = $cmdLine[4] 20 | EndIf 21 | 22 | if FileExists(@WorkingDir&"\config.ini")=0 Then 23 | IniWrite(@WorkingDir&"\config.ini", "General", "FontSize", $FontSize) 24 | IniWrite(@WorkingDir&"\config.ini", "General", "TextItemWidth", "50") 25 | IniWrite(@WorkingDir&"\config.ini", "General", "TextItemHeight", "50") 26 | IniWrite(@WorkingDir&"\config.ini", "General", "Language", $Language) 27 | Else 28 | $FontSize = IniRead (@WorkingDir&"\config.ini", "General", "FontSize", 6 ) 29 | $TextItemWidth = IniRead (@WorkingDir&"\config.ini", "General", "TextItemWidth", 50 ) 30 | $TextItemHeight = IniRead (@WorkingDir&"\config.ini", "General", "TextItemHeight", 50 ) 31 | $Language = IniRead (@WorkingDir&"\config.ini", "General", "Language", 1 ) 32 | Endif 33 | ConsoleWrite($FontSize) 34 | 35 | Local $hFileOpen = FileOpen(@WorkingDir&"\out.txt", $FO_READ) 36 | If $hFileOpen = -1 Then 37 | MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file(out.txt does not exist).") 38 | Return False 39 | EndIf 40 | 41 | Local $fsFileOpen = FileOpen(@WorkingDir&"\font.txt", $FO_READ) 42 | Local $font = "" 43 | If $fsFileOpen <> -1 Then 44 | $font=FileRead($fsFileOpen) 45 | EndIf 46 | 47 | Global $app = ObjCreate("Photoshop.Application") 48 | $app.Preferences.RulerUnits = 1 49 | $app.Preferences.TypeUnits = 5 50 | 51 | Global $doc 52 | Global $filename = "" 53 | Global $previousFilename = "" 54 | Global $fileindex=0 55 | Global $index = 1 56 | 57 | While True 58 | $line=FileReadLine($hFileOpen) 59 | if @error Then ExitLoop 60 | $lineSplit=StringSplit($line, @TAB) 61 | ConsoleWrite($lineSplit) 62 | $X=$lineSplit[1] 63 | $Y=$lineSplit[2] 64 | $width=$lineSplit[3] 65 | $height=$lineSplit[4] 66 | $filename=$lineSplit[5] 67 | $filenameWithoutExtention=StringLeft($filename, StringInStr($filename,".",0,-1)-1) 68 | $previousFilenameWithoutExtention=StringLeft($previousFilename, StringInStr($previousFilename,".",0,-1)-1) 69 | $bgcolor=$lineSplit[6] 70 | $pfontsize=$lineSplit[8] 71 | $lineheight=$lineSplit[9] 72 | $fontname=$lineSplit[10] 73 | $fontcolor=$lineSplit[11] 74 | $direction=$lineSplit[12] 75 | $alignment=$lineSplit[13] 76 | if $previousFilename<>$filename Then 77 | if $previousFilename<>"" Then 78 | if $flip=1 Then 79 | flip($doc) 80 | EndIf 81 | SaveAndClose($doc,@WorkingDir &"\"& $previousFilenameWithoutExtention & ".psd") 82 | $index=1 83 | EndIf 84 | $fileindex=$fileindex+1 85 | if FileExists(@WorkingDir &"\"& $fileName) Then 86 | $doc = $app.open(@WorkingDir &"\"& $fileName) 87 | $previousFilename=$filename 88 | if $precisionMode = 1 and $addMask=1 Then 89 | $maskImgPath=@WorkingDir & "\" & $filename & "-text-removed.jpg" 90 | if FileExists($maskImgPath) Then 91 | addPreciseMask($maskImgPath,$doc) 92 | EndIf 93 | EndIf 94 | Else 95 | ContinueLoop 96 | EndIf 97 | EndIf 98 | $text=StringRight($line, StringLen($line) - StringInStr($line,@TAB,0,20)) 99 | $text=StringReplace($text, "\n", @CR) 100 | ConsoleWrite($X & @CRLF) 101 | ConsoleWrite($Y & @CRLF) 102 | ConsoleWrite($width & @CRLF) 103 | ConsoleWrite($height & @CRLF) 104 | ;ConsoleWrite($doc.Width & @CRLF) 105 | ;ConsoleWrite($doc.Height & @CRLF) 106 | ConsoleWrite($filename & @CRLF) 107 | ConsoleWrite($bgcolor & @CRLF) 108 | ConsoleWrite($text & @CRLF) 109 | addLayer($doc,$X,$Y,$width,$height,$text,$bgcolor,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 110 | WEnd 111 | 112 | ConsoleWrite("end" & $filename) 113 | $filenameWithoutExtention=StringLeft($filename, StringInStr($filename,".",0,-1)-1) 114 | if $flip=1 Then 115 | flip($doc) 116 | EndIf 117 | SaveAndClose($doc,@WorkingDir &"\"& $filenameWithoutExtention & ".psd") 118 | 119 | MsgBox(64,"","Layers Added") 120 | 121 | Func flip($doc) 122 | $doc.FlipCanvas(1) 123 | $LayerSets=$doc.LayerSets 124 | $ArtLayers=$doc.ArtLayers 125 | flipLayerSets($LayerSets) 126 | flipArtLayers($ArtLayers) 127 | EndFunc 128 | 129 | Func flipLayerSets($LayerSets) 130 | For $i=1 to $LayerSets.Count 131 | $LayerSet=$LayerSets.Item($i) 132 | flipArtLayers($LayerSet.ArtLayers) 133 | flipLayerSets($LayerSet.LayerSets) 134 | Next 135 | EndFunc 136 | 137 | Func flipArtLayers($ArtLayers) 138 | For $i=1 to $ArtLayers.Count 139 | $ArtLayer=$ArtLayers.Item($i) 140 | if $ArtLayer.Kind=2 Then 141 | ConsoleWrite("textLayer" & @CRLF) 142 | $ArtLayer.Resize(-100,100,5) 143 | EndIf 144 | Next 145 | EndFunc 146 | 147 | Func SaveAndClose($doc,$path) 148 | SaveAs($doc,$path) 149 | $doc.close(2); don't save 150 | EndFunc 151 | 152 | 153 | 154 | Func addPreciseMask($path,$doc) 155 | $maskDoc = $app.open($path) 156 | $backLayer=$maskDoc.ArtLayers.Item(1) 157 | $backLayer.copy() 158 | Dim $bounds[4] 159 | $bounds=$backLayer.Bounds 160 | $maskDoc.close(2) 161 | $targetLayer=$doc.paste() 162 | Dim $targetBounds[4] 163 | $targetBounds=$targetLayer.Bounds 164 | $targetLayer.ApplyOffset($bounds[0]-$targetBounds[0],$bounds[1]-$targetBounds[1],3) 165 | EndFunc 166 | 167 | Func addLayer($doc,$X,$Y,$width,$height,$text,$bgcolor,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 168 | if $bgcolor<>"transparent" and $addMask=1 Then 169 | if $precisionMode=0 Then 170 | Dim $maskArtLayer = $doc.artLayers.add() 171 | Dim $Position[2] 172 | $Position[0]=$X 173 | $Position[1]=$Y 174 | $maskArtLayer.bounds=$Position 175 | $maskArtLayer.name="mask "&$index 176 | Dim $color = getSolidColor($bgcolor) 177 | Dim $region[5] 178 | Dim $arr1[2] 179 | $arr1[0]=$X 180 | $arr1[1]=$Y 181 | Dim $arr2[2] 182 | $arr2[0]=$X 183 | $arr2[1]=$Y+$height 184 | Dim $arr3[2] 185 | $arr3[0]=$x+$width 186 | $arr3[1]=$y+$height 187 | Dim $arr4[2] 188 | $arr4[0]=$x+$width 189 | $arr4[1]=$Y 190 | $region[0]=$arr1 191 | $region[1]=$arr2 192 | $region[2]=$arr3 193 | $region[3]=$arr4 194 | $region[4]=$arr4 195 | $doc.Selection.Select($region) 196 | $doc.Selection.Fill($color) 197 | $index=$index+1 198 | EndIf 199 | EndIf 200 | 201 | Dim $res = $doc.Resolution 202 | Dim $textLayer = $doc.artLayers.add() 203 | $textLayer.Kind=2 204 | $textLayer.textItem.Kind= int($textKind) 205 | $textLayer.textItem.Contents = $text 206 | ConsoleWrite("size:"&$FontSize) 207 | $textLayer.textItem.Size = Int($pfontsize) 208 | Dim $Position[2] 209 | $Position[0]=int($X) 210 | $Position[1]=int($Y) 211 | $textLayer.textItem.Position=$Position 212 | ConsoleWrite(int($width) & @CRLF) 213 | ConsoleWrite($doc.Width) 214 | ;$textLayer.textItem.Width=int($TextItemWidth) 215 | ;$textLayer.textItem.Height=int($TextItemHeight) 216 | ;ConsoleWrite("width" & $width & @CRLF) 217 | ;ConsoleWrite("height" & $height & @CRLF) 218 | 219 | $width=$width/$res*72 220 | $height=$height/$res*72 221 | 222 | $textLayer.textItem.Font= $fontname 223 | $textLayer.textItem.Width=int($width) 224 | $textLayer.textItem.Height=int($height) 225 | $textLayer.textItem.Justification=int($alignment) 226 | $textLayer.textItem.Capitalization=2 ;capcase 227 | $textLayer.textItem.Language= int($Language) 228 | $textLayer.textItem.Hyphenation = True 229 | $textLayer.textItem.UseAutoLeading = False 230 | $textLayer.textItem.Leading=Ceiling($textLayer.textItem.Size)*$lineheight 231 | $textLayer.textItem.Direction = int($direction) 232 | Dim $fColor = getSolidColor($fontcolor) 233 | $textLayer.textItem.Color=$fColor 234 | ConsoleWrite(@CRLF & "res" & $res & @CRLF) 235 | ;ConsoleWrite("width" & $textLayer.textItem.Width & @CRLF) 236 | ;ConsoleWrite("height" & $textLayer.textItem.Height & @CRLF) 237 | EndFunc 238 | 239 | Func getSolidColor($colorString) 240 | Dim $colors[3] 241 | $colors = StringSplit($colorString,",") 242 | ConsoleWrite($colors[1] & @CRLF) 243 | ConsoleWrite($colors[2] & @CRLF) 244 | ConsoleWrite($colors[3] & @CRLF) 245 | Dim $r = $colors[1] 246 | Dim $g = $colors[2] 247 | Dim $b = $colors[3] 248 | Dim $color = ObjCreate("Photoshop.SolidColor") 249 | $color.RGB.Red=int($r) 250 | $color.RGB.Green=int($g) 251 | $color.RGB.Blue=int($b) 252 | return $color 253 | EndFunc 254 | 255 | Func SaveAsJPG($doc,$path) 256 | Dim $ObjSaveOptions=ObjCreate("Photoshop.JPEGSaveOptions") 257 | ;if @error Then Exit 258 | With $ObjSaveOptions 259 | .EmbedColorProfile = True 260 | .FormatOptions = 1 261 | .Matte = 1 262 | .Quality = 12 263 | EndWith 264 | ConsoleWrite($path&@CRLF) 265 | $doc.SaveAS($path,$ObjSaveOptions,True,2) 266 | EndFunc 267 | 268 | Func SaveAs($doc,$path) 269 | Dim $ObjSaveOptions=ObjCreate("Photoshop.PhotoshopSaveOptions") 270 | ;if @error Then Exit 271 | With $ObjSaveOptions 272 | .Layers = True 273 | EndWith 274 | ConsoleWrite($path&@CRLF) 275 | $doc.SaveAS($path,$ObjSaveOptions,True,2) 276 | EndFunc -------------------------------------------------------------------------------- /au3/addLayers4PSD.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Global $FontSize = 6 5 | Global $addMask 6 | Global $precisionMode = 0 ;1 yes, 0 no 7 | Global $flip = 0 ;1 yes, 0 no 8 | Global $textKind = 2 ;1 point, 2 paragraph 9 | ConsoleWrite( $cmdLine[0] & @CRLF) 10 | 11 | if $cmdLine[0]<>4 Then 12 | $addMask=1 ; 0 don't, 1 add. 13 | $textKind=1 14 | Else 15 | $addMask=$cmdLine[1] 16 | $precisionMode = $cmdLine[2] 17 | $flip = $cmdLine[3] 18 | $textKind = $cmdLine[4] 19 | EndIf 20 | 21 | Global $TextItemWidth = 50 22 | Global $TextItemHeight = 50 23 | Global $Language = 1 24 | 25 | if FileExists(@WorkingDir&"\config.ini")=0 Then 26 | IniWrite(@WorkingDir&"\config.ini", "General", "FontSize", $FontSize) 27 | IniWrite(@WorkingDir&"\config.ini", "General", "TextItemWidth", "50") 28 | IniWrite(@WorkingDir&"\config.ini", "General", "TextItemHeight", "50") 29 | IniWrite(@WorkingDir&"\config.ini", "General", "Language", $Language) 30 | Else 31 | $FontSize = IniRead (@WorkingDir&"\config.ini", "General", "FontSize", 6 ) 32 | $TextItemWidth = IniRead (@WorkingDir&"\config.ini", "General", "TextItemWidth", 50 ) 33 | $TextItemHeight = IniRead (@WorkingDir&"\config.ini", "General", "TextItemHeight", 50 ) 34 | $Language = IniRead (@WorkingDir&"\config.ini", "General", "Language", 1 ) 35 | Endif 36 | ConsoleWrite($FontSize) 37 | 38 | Local $fsFileOpen = FileOpen(@WorkingDir&"\font.txt", $FO_READ) 39 | Local $font = "" 40 | If $fsFileOpen <> -1 Then 41 | $font=FileRead($fsFileOpen) 42 | EndIf 43 | 44 | Local $hFileOpen = FileOpen(@WorkingDir&"\out.txt", $FO_READ) 45 | If $hFileOpen = -1 Then 46 | MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file(out.txt does not exist).") 47 | Return False 48 | EndIf 49 | 50 | Global $app = ObjCreate("Photoshop.Application") 51 | $app.Preferences.RulerUnits = 1 52 | $app.Preferences.TypeUnits = 5 53 | 54 | Global $doc 55 | 56 | Global $previousFilename = "" 57 | Global $filename = "" 58 | Global $fileindex=0 59 | Global $index = 1 60 | 61 | While True 62 | $line=FileReadLine($hFileOpen) 63 | if @error Then ExitLoop 64 | $lineSplit=StringSplit($line, @TAB) 65 | ConsoleWrite($lineSplit) 66 | $X=$lineSplit[1] 67 | $Y=$lineSplit[2] 68 | $width=$lineSplit[3] 69 | $height=$lineSplit[4] 70 | $filename=$lineSplit[5] 71 | $filenameWithoutExtention=StringLeft($filename, StringInStr($filename,".",0,-1)-1) 72 | $bgcolor=$lineSplit[6] 73 | $layername=$lineSplit[7] 74 | $pfontsize=$lineSplit[8] 75 | $lineheight=$lineSplit[9] 76 | $fontname=$lineSplit[10] 77 | $fontcolor=$lineSplit[11] 78 | $direction=$lineSplit[12] 79 | $alignment=$lineSplit[13] 80 | if $previousFilename<>$filenameWithoutExtention Then 81 | if $previousFilename<>"" Then 82 | if $flip=1 Then 83 | flip($doc) 84 | EndIf 85 | SaveAndClose($doc,@WorkingDir &"\"& $previousFilename & ".psd") 86 | $index=1 87 | EndIf 88 | $fileindex=$fileindex+1 89 | if FileExists(@WorkingDir &"\"& $fileName) Then 90 | $doc = $app.open(@WorkingDir &"\"& $filenameWithoutExtention & ".psd") 91 | $previousFilename=$filenameWithoutExtention 92 | if $precisionMode = 1 and $addMask=1 Then 93 | $maskImgPath=@WorkingDir & "\" & $filename & "-text-removed.jpg" 94 | if FileExists($maskImgPath) Then 95 | addPreciseMask($maskImgPath,$doc) 96 | EndIf 97 | EndIf 98 | Else 99 | ContinueLoop 100 | EndIf 101 | EndIf 102 | $text=StringRight($line, StringLen($line) - StringInStr($line,@TAB,0,20)) 103 | $text=StringReplace($text, "\n", @CR) 104 | ConsoleWrite($X & @CRLF) 105 | ConsoleWrite($Y & @CRLF) 106 | ConsoleWrite($width & @CRLF) 107 | ConsoleWrite($height & @CRLF) 108 | ;ConsoleWrite($doc.Width & @CRLF) 109 | ;ConsoleWrite($doc.Height & @CRLF) 110 | ConsoleWrite($filename & @CRLF) 111 | ConsoleWrite($bgcolor & @CRLF) 112 | ConsoleWrite($text & @CRLF) 113 | if $layername="NotALayer" Then 114 | addLayer($doc,$X,$Y,$width,$height,$text,$bgcolor,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 115 | Else 116 | import($doc,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 117 | EndIf 118 | WEnd 119 | 120 | ConsoleWrite("end" & $filename) 121 | $filenameWithoutExtention=StringLeft($filename, StringInStr($filename,".",0,-1)-1) 122 | if $flip=1 Then 123 | flip($doc) 124 | EndIf 125 | SaveAndClose($doc,@WorkingDir &"\"& $filenameWithoutExtention & ".psd") 126 | MsgBox(64,"","Layers Added") 127 | 128 | Func SaveAndClose($doc,$path) 129 | SaveAs($doc,$path) 130 | $doc.close(2); don't save 131 | EndFunc 132 | 133 | Func flip($doc) 134 | $doc.FlipCanvas(1) 135 | $LayerSets=$doc.LayerSets 136 | $ArtLayers=$doc.ArtLayers 137 | flipLayerSets($LayerSets) 138 | flipArtLayers($ArtLayers) 139 | EndFunc 140 | 141 | Func flipLayerSets($LayerSets) 142 | For $i=1 to $LayerSets.Count 143 | $LayerSet=$LayerSets.Item($i) 144 | flipArtLayers($LayerSet.ArtLayers) 145 | flipLayerSets($LayerSet.LayerSets) 146 | Next 147 | EndFunc 148 | 149 | Func flipArtLayers($ArtLayers) 150 | For $i=1 to $ArtLayers.Count 151 | $ArtLayer=$ArtLayers.Item($i) 152 | if $ArtLayer.Kind=2 Then 153 | ConsoleWrite("textLayer" & @CRLF) 154 | $ArtLayer.Resize(-100,100,5) 155 | EndIf 156 | Next 157 | EndFunc 158 | 159 | Func addPreciseMask($path,$doc) 160 | $maskDoc = $app.open($path) 161 | $backLayer=$maskDoc.ArtLayers.Item(1) 162 | $backLayer.copy() 163 | Dim $bounds[4] 164 | $bounds=$backLayer.Bounds 165 | $maskDoc.close(2) 166 | $targetLayer=$doc.paste() 167 | Dim $targetBounds[4] 168 | $targetBounds=$targetLayer.Bounds 169 | $targetLayer.ApplyOffset($bounds[0]-$targetBounds[0],$bounds[1]-$targetBounds[1],3) 170 | EndFunc 171 | 172 | Func addLayer($doc,$X,$Y,$width,$height,$text,$bgcolor,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 173 | if $bgcolor<>"transparent" and $addMask=1 Then 174 | if $precisionMode=0 Then 175 | Dim $maskArtLayer = $doc.artLayers.add() 176 | Dim $Position[2] 177 | $Position[0]=$X 178 | $Position[1]=$Y 179 | $maskArtLayer.bounds=$Position 180 | $maskArtLayer.name="mask "&$index 181 | Dim $color = getSolidColor($bgcolor) 182 | Dim $region[5] 183 | Dim $arr1[2] 184 | $arr1[0]=$X 185 | $arr1[1]=$Y 186 | Dim $arr2[2] 187 | $arr2[0]=$X 188 | $arr2[1]=$Y+$height 189 | Dim $arr3[2] 190 | $arr3[0]=$x+$width 191 | $arr3[1]=$y+$height 192 | Dim $arr4[2] 193 | $arr4[0]=$x+$width 194 | $arr4[1]=$Y 195 | $region[0]=$arr1 196 | $region[1]=$arr2 197 | $region[2]=$arr3 198 | $region[3]=$arr4 199 | $region[4]=$arr4 200 | $doc.Selection.Select($region) 201 | $doc.Selection.Fill($color) 202 | $index=$index+1 203 | EndIf 204 | EndIf 205 | 206 | Dim $res = $doc.Resolution 207 | Dim $textLayer = $doc.artLayers.add() 208 | 209 | $textLayer.Kind=2 210 | $textLayer.textItem.Kind= int($textKind) 211 | $textLayer.textItem.Contents = $text 212 | ConsoleWrite("size:"&$FontSize) 213 | $textLayer.textItem.Size = Int($pfontsize) 214 | Dim $Position[2] 215 | $Position[0]=int($X) 216 | $Position[1]=int($Y) 217 | $textLayer.textItem.Position=$Position 218 | ConsoleWrite(int($width) & @CRLF) 219 | ConsoleWrite($doc.Width) 220 | ;$textLayer.textItem.Width=int($TextItemWidth) 221 | ;$textLayer.textItem.Height=int($TextItemHeight) 222 | ;ConsoleWrite("width" & $width & @CRLF) 223 | ;ConsoleWrite("height" & $height & @CRLF) 224 | 225 | $width=$width/$res*72 226 | $height=$height/$res*72 227 | 228 | $textLayer.textItem.Font= $fontname 229 | $textLayer.textItem.Width=int($width) 230 | $textLayer.textItem.Height=int($height) 231 | $textLayer.textItem.Justification=int($alignment) 232 | $textLayer.textItem.Capitalization=2 ;capcase 233 | $textLayer.textItem.Language= int($Language) 234 | $textLayer.textItem.Hyphenation = True 235 | $textLayer.textItem.UseAutoLeading = False 236 | $textLayer.textItem.Leading=Ceiling($textLayer.textItem.Size)*$lineheight 237 | $textLayer.textItem.Direction = int($direction) 238 | Dim $fColor = getSolidColor($fontcolor) 239 | $textLayer.textItem.Color=$fColor 240 | ;ConsoleWrite("width" & $textLayer.textItem.Width & @CRLF) 241 | ;ConsoleWrite("height" & $textLayer.textItem.Height & @CRLF) 242 | 243 | EndFunc 244 | 245 | Func getSolidColor($colorString) 246 | Dim $colors[3] 247 | $colors = StringSplit($colorString,",") 248 | ConsoleWrite($colors[1] & @CRLF) 249 | ConsoleWrite($colors[2] & @CRLF) 250 | ConsoleWrite($colors[3] & @CRLF) 251 | Dim $r = $colors[1] 252 | Dim $g = $colors[2] 253 | Dim $b = $colors[3] 254 | Dim $color = ObjCreate("Photoshop.SolidColor") 255 | $color.RGB.Red=int($r) 256 | $color.RGB.Green=int($g) 257 | $color.RGB.Blue=int($b) 258 | return $color 259 | EndFunc 260 | 261 | Func SaveAsJPG($doc,$path) 262 | Dim $ObjSaveOptions=ObjCreate("Photoshop.JPEGSaveOptions") 263 | ;if @error Then Exit 264 | With $ObjSaveOptions 265 | .EmbedColorProfile = True 266 | .FormatOptions = 1 267 | .Matte = 1 268 | .Quality = 12 269 | EndWith 270 | ConsoleWrite($path&@CRLF) 271 | $doc.SaveAS($path,$ObjSaveOptions,True,2) 272 | EndFunc 273 | 274 | Func SaveAs($doc,$path) 275 | Dim $ObjSaveOptions=ObjCreate("Photoshop.PhotoshopSaveOptions") 276 | ;if @error Then Exit 277 | With $ObjSaveOptions 278 | .Layers = True 279 | EndWith 280 | ConsoleWrite($path&@CRLF) 281 | $doc.SaveAS($path,$ObjSaveOptions,True,2) 282 | EndFunc 283 | 284 | Func import($doc,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 285 | $LayerSets=$doc.LayerSets 286 | $ArtLayers=$doc.ArtLayers 287 | handleLayerSets($LayerSets,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 288 | handleArtLayers($ArtLayers,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 289 | EndFunc 290 | 291 | Func handleLayerSets($LayerSets,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 292 | For $i=1 to $LayerSets.Count 293 | $LayerSet=$LayerSets.Item($i) 294 | handleArtLayers($LayerSet.ArtLayers,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 295 | handleLayerSets($LayerSet.LayerSets,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 296 | Next 297 | EndFunc 298 | 299 | Func handleArtLayers($ArtLayers,$text,$layername,$pfontsize,$lineheight,$fontname,$fontcolor,$direction,$alignment) 300 | For $i=1 to $ArtLayers.Count 301 | $ArtLayer=$ArtLayers.Item($i) 302 | Dim $bounds[4] 303 | $bounds=$ArtLayer.Bounds 304 | Dim $position[2] ; two values 305 | $position[0]=$bounds[0] 306 | $position[1]=$bounds[1] 307 | if $layerName=$ArtLayer.name Then 308 | if $ArtLayer.Kind=1 Then 309 | $ArtLayer.clear() 310 | $ArtLayer.Kind = 2 311 | $ArtLayer.textItem.Kind=int($textKind) 312 | $ArtLayer.textItem.Width=Ceiling($TextItemWidth) 313 | $ArtLayer.textItem.Height=Ceiling($TextItemHeight) 314 | $ArtLayer.textItem.Size=Ceiling($pfontsize) 315 | $ArtLayer.textItem.Position=$position 316 | $ArtLayer.name=$text 317 | Else 318 | $ArtLayer.textItem.Kind=int($textKind) 319 | EndIf 320 | $ArtLayer.textItem.Contents = $text 321 | $ArtLayer.textItem.Font= $fontname 322 | $ArtLayer.textItem.Justification=int($alignment) 323 | $ArtLayer.textItem.Capitalization=2 ;capcase 324 | $ArtLayer.textItem.Language= int($Language) 325 | $ArtLayer.textItem.Hyphenation = True 326 | $ArtLayer.textItem.UseAutoLeading = False 327 | $ArtLayer.textItem.Leading=Ceiling($ArtLayer.textItem.Size)*$lineheight 328 | $ArtLayer.textItem.Direction = int($direction) 329 | Dim $fColor = getSolidColor($fontcolor) 330 | $ArtLayer.textItem.Color=$fColor 331 | Endif 332 | Next 333 | EndFunc -------------------------------------------------------------------------------- /au3/readFont.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | $app = ObjCreate("Photoshop.Application") 5 | if @error Then Exit 6 | $doc=$app.activeDocument 7 | $Layers=$doc.ArtLayers 8 | handleLayers($Layers) 9 | 10 | 11 | Func handleLayers($pLayers) 12 | For $i=1 to $pLayers.Count 13 | $Layer=$pLayers.Item($i) 14 | if $Layer.Kind = 2 Then 15 | ConsoleWrite($Layer.textItem.Font) 16 | Local $hFileOpen = FileOpen( @WorkingDir & "\font.txt", $FO_OVERWRITE) 17 | If $hFileOpen = -1 Then 18 | MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") 19 | Return False 20 | EndIf 21 | FileWrite($hFileOpen, $Layer.textItem.Font) 22 | FileClose($hFileOpen) 23 | Exit 24 | Endif 25 | Next 26 | EndFunc 27 | -------------------------------------------------------------------------------- /au3/readTextLayers.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Dim $filename 5 | 6 | if $cmdLine[0]<>1 Then 7 | $filename="test.psd" 8 | ;Exit(1) 9 | Else 10 | $filename=$cmdLine[1] 11 | EndIf 12 | 13 | Local $hFileOpen = FileOpen(@WorkingDir & "\" & $filename&".txt", $FO_OVERWRITE) 14 | If $hFileOpen = -1 Then 15 | MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") 16 | Return False 17 | EndIf 18 | 19 | 20 | ;MsgBox(64,$filename,$layerName) 21 | 22 | $app = ObjCreate("Photoshop.Application") 23 | $app.Preferences.RulerUnits = 1 24 | $app.Preferences.TypeUnits = 5 25 | $doc = $app.open(@WorkingDir & "\" & $fileName) 26 | 27 | $res=$doc.Resolution 28 | 29 | $LayerSets=$doc.LayerSets 30 | $ArtLayers=$doc.ArtLayers 31 | handleLayerSets($LayerSets) 32 | handleArtLayers($ArtLayers) 33 | FileClose($hFileOpen) 34 | $doc.close(2) 35 | 36 | Func handleLayerSets($LayerSets) 37 | For $i=1 to $LayerSets.Count 38 | $LayerSet=$LayerSets.Item($i) 39 | handleArtLayers($LayerSet.ArtLayers) 40 | handleLayerSets($LayerSet.LayerSets) 41 | Next 42 | EndFunc 43 | 44 | Func handleArtLayers($ArtLayers) 45 | ConsoleWrite("handling") 46 | For $i=1 to $ArtLayers.Count 47 | $ArtLayer=$ArtLayers.Item($i) 48 | if $ArtLayer.Kind=2 Then 49 | Dim $bounds[4] 50 | $bounds=$ArtLayer.Bounds 51 | Dim $position[2] ; two values 52 | $position[0]=$bounds[0] 53 | $position[1]=$bounds[1] 54 | $layername=$ArtLayer.Name 55 | $content=$ArtLayer.textItem.Contents 56 | if $content="" Then 57 | ContinueLoop 58 | EndIf 59 | $ArtLayer.textItem.Kind=1 ;point 60 | ;$ArtLayer.textItem.Contents=$content & @CRLF 61 | $ArtLayer.textItem.Kind=2 ;paragraph 62 | ConsoleWrite(@CRLF) 63 | ConsoleWrite($position[0] & @CRLF) 64 | ConsoleWrite($position[1] & @CRLF) 65 | ConsoleWrite($ArtLayer.textItem.Width & @CRLF) 66 | ConsoleWrite($ArtLayer.textItem.Height & @CRLF) 67 | 68 | $content=StringReplace($content,@CRLF,"\n") 69 | $content=StringReplace($content,@CR,"\n") 70 | $content=StringReplace($content,@LF,"\n") 71 | ;$content=StringRegExpReplace($content,"\r","") 72 | $layername=$ArtLayer.Name 73 | Dim $scale 74 | $scale=$res/72 75 | 76 | $text=$position[0] & @TAB & $position[1] & @TAB & $ArtLayer.textItem.Width*$scale*$scale & @TAB & $ArtLayer.textItem.Height*$scale*$scale & @TAB & $layername & @TAB & $content 77 | FileWriteLine($hFileOpen,$text) 78 | EndIf 79 | Next 80 | EndFunc 81 | 82 | -------------------------------------------------------------------------------- /au3/test.au3: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Local $hFileOpen = FileOpen(@WorkingDir&"\out.txt", $FO_READ) 5 | If $hFileOpen = -1 Then 6 | MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file(out.txt does not exist).") 7 | Return False 8 | EndIf 9 | 10 | $line=FileReadLine($hFileOpen) 11 | ConsoleWrite($line&@CRLF) 12 | $lineSplit=StringSplit($line, @TAB) 13 | 14 | 15 | $text=StringRight($line, StringLen($line) - StringInStr($line,@TAB,0,20)) 16 | ConsoleWrite($text) -------------------------------------------------------------------------------- /psd2jpg.jsx: -------------------------------------------------------------------------------- 1 | var layerIsFound=false; 2 | var inputFolder = Folder.selectDialog("Select a folder to process"); 3 | var psdList=[]; 4 | getPSDList(inputFolder.toString()) 5 | for(var i=0; i