Skip to main content
neirmourao
Participating Frequently
April 1, 2025
질문

Ajuda com script no Photoshop para automatizar alterações de tamanho em formas.

  • April 1, 2025
  • 4 답변들
  • 1384 조회

Olá, pessoal! Primeira vez postando aqui. Não encontrei nada relacionado à minha dúvida, então decidi compartilhar.

Estou tentando criar um script para automatizar uma tarefa no Photoshop que envolve redimensionar formas e fontes em um arquivo de cotas. O problema é que, ao redimensionar a imagem de 3024x3024px para 1500x1500px, as fontes e formas ficam muito pequenas. Por exemplo, as linhas que têm altura de 1px no arquivo original ficam com 0,5px, e as setas que tinham altura e largura de 10px com traçado de 1,5px diminuem para 4,96px de altura/largura e 0,74px de espessura. As fontes também encolhem muito (antes eram 6pt e 4,7pt, mas depois ficam menores).

Já tentei selecionar todas as linhas e ajustar para 1px de altura, mas não funciona. Também tentei transformar as formas em objetos inteligentes, mas não deu certo.

Criei um script com a ajuda do ChatGPT, mas ele sempre retorna o erro 1320. Tentei dividir o script em partes, uma para as linhas, outra para as setas e uma para o texto, e consegui fazer funcionar só para o texto. As outras partes continuam gerando o erro 1320. Como tenho muitas imagens para ajustar, estou tentando uma solução mais rápida.

Vou deixar abaixo o script que tentei (mas que não funcionou) e também uma imagem de exemplo. Se alguém puder ajudar, seria ótimo! Agradeço desde já!

/* Script Photoshop JSX: Ajustar Altura das Formas para 1px via Transformar

  • Modifica diretamente a propriedade de altura da camada na aba Transformar.

  • Processa camada por camada individualmente para evitar erros. */

if (app.documents.length > 0) { var doc = app.activeDocument;

function setHeightToOnePixel(layer) {
    if (layer.kind == LayerKind.SHAPE) {
        // Seleciona a camada
        doc.activeLayer = layer;

        // Abre o painel de transformação
        var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
        desc.putReference(charIDToTypeID("null"), ref);

        // Define a nova altura como 1px
        var heightDesc = new ActionDescriptor();
        heightDesc.putUnitDouble(charIDToTypeID("Hght"), charIDToTypeID("#Pxl"), 1);
        desc.putObject(charIDToTypeID("T "), charIDToTypeID("Trnf"), heightDesc);

        // Aplica a transformação
        executeAction(charIDToTypeID("setd"), desc, DialogModes.NO);
    }
}

function processLayers(layerSet) {
    for (var i = 0; i < layerSet.artLayers.length; i++) {
        setHeightToOnePixel(layerSet.artLayers[i]);
    }

    // Processa subgrupos, se houver
    for (var j = 0; j < layerSet.layerSets.length; j++) {
        processLayers(layerSet.layerSets[j]);
    }
}

processLayers(doc);

// Atualiza a visualização
app.refresh();
alert("Todas as linhas foram ajustadas para 1px de altura!");

} else { alert("Nenhum documento aberto."); }



4 답변

c.pfaffenbichler
Community Expert
Community Expert
August 15, 2025

The google-link does not seem to work anymore, could you please provide the file again? 

You seem to mix the terms shapes and strokes so I am not sure what the graphic elements actually are (Shape Layers with just Stroke, or Fill or Fill and Stroke). 

Inspiring
April 18, 2025

I tried some ideas unfortunately I couldn't create anything valid.

sorry.

neirmourao
neirmourao작성자
Participating Frequently
May 6, 2025

thanks anyway for your time 

neirmourao
neirmourao작성자
Participating Frequently
May 6, 2025

and sorry my bad english, i'm brazilian. I study english but my level is B2  

Ancelmo Alves
Known Participant
April 14, 2025
It's a little confusing, but are you trying to re-mention a PSD file?
neirmourao
neirmourao작성자
Participating Frequently
May 6, 2025

keep the size of shapes after re-mention the object

Inspiring
April 2, 2025

It's normal, if you size 50% everything will be resized to 50%, shapes, text and more,
what would you like to do?
resize the image and leave shapes and text the same size?

neirmourao
neirmourao작성자
Participating Frequently
April 2, 2025

Yes, that's right. But in a way that keeps the dimension lines and arrows in the same place.

Inspiring
April 2, 2025

You could try but the result would not be consistent, because everything will be scaled and the lines and arrows will not.