Murilo337970028e6d
New Here
Murilo337970028e6d
New Here
Activity
‎Nov 22, 2023
02:23 PM
Follow the right code even is not working // 1° Determinar pasta fonte das imagens var sourceFolder = Folder.selectDialog("Select the source folder"); // 2° Determinar pasta no qual receberá novas imagens var destinationFolder = Folder.selectDialog("Select the destination folder"); // Get all files in the source folder var files = sourceFolder.getFiles(); // Loop over all files for (var i = 0; i < files.length; i++) { // Open the file var doc = app.open(files[i]); // 3° Desbloquear o cadeado, transformando em camada var layer = doc.activeLayer; layer.blendMode = BlendMode.NORMAL; layer.opacity = 100; // 4° Aparar imagem doc.trim(TrimType.TOPLEFT, true, true, true, true); // 5° Determinando o maior lado da imagem var longestSide = Math.max(layer.width, layer.height); var scaleFactor = (1200 / longestSide)*100 // 6° Alterar tela de pintura 1200x1200 doc.resizeCanvas(1200, 1200, AnchorPosition.MIDDLECENTER); // 7° CRTL+T (Transformação livre alterando a imagem para o novo tamanho calculado layer.resize(scaleFactor, scaleFactor, AnchorPosition.MIDDLECENTER); })(); ; // 8° Save as imagem var saveFile = new File(destinationFolder + "/" + files[i].name); doc.saveAs(saveFile, SaveOptions.PNG); // 9° Fechar a imagem doc.close(SaveOptions.DONOTSAVECHANGES); }
... View more
‎Nov 22, 2023
11:48 AM
2 Upvotes
I'm writing a script to Trim an Image record the current width, calculate new width and increase in the image. Here is the code below, but have issues in the layer.resize. Anyone know, whats the problem? // 1° Determinar pasta fonte das imagens var sourceFolder = Folder.selectDialog("Select the source folder"); // 2° Determinar pasta no qual receberá novas imagens var destinationFolder = Folder.selectDialog("Select the destination folder"); // Get all files in the source folder var files = sourceFolder.getFiles(); // Loop over all files for (var i = 0; i < files.length; i++) { // Open the file var doc = app.open(files[i]); // 3° Desbloquear o cadeado, transformando em camada var layer = doc.activeLayer; layer.blendMode = BlendMode.NORMAL; layer.opacity = 100; // 4° Aparar imagem doc.trim(TrimType.TOPLEFT, true, true, true, true); // 5° Determinando o maior lado da imagem var longestSide = Math.max(layer.width, layer.height); var scaleFactor = (1200 / longestSide)*100 // 6° Alterar tela de pintura 1200x1200 doc.resizeCanvas(1200, 1200, AnchorPosition.MIDDLECENTER); // 7° CRTL+T (Transformação livre alterando a imagem para o novo tamanho calculado layer.resize(newWidth, newHeight, AnchorPosition.MIDDLECENTER); })(); ; // 8° Save as imagem var saveFile = new File(destinationFolder + "/" + files[i].name); doc.saveAs(saveFile, SaveOptions.PNG); // 9° Fechar a imagem doc.close(SaveOptions.DONOTSAVECHANGES); }
... View more