Skip to main content
neirmourao
Participating Frequently
Apr 1, 2025 12:18 PM UTC
Question

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

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."); }



14 replies

c.pfaffenbichler
Community Expert
Community Expert
Aug 15, 2025 12:50 PM UTC

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). 

Translate
Inspiring
Apr 18, 2025 3:19 PM UTC

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

sorry.

Translate
neirmourao
Participating Frequently
May 6, 2025 6:52 PM UTC

thanks anyway for your time 

Translate
neirmourao
Participating Frequently
May 6, 2025 6:55 PM UTC

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

Translate
Ancelmo Alves
Known Participant
Apr 14, 2025 11:02 PM UTC
It's a little confusing, but are you trying to re-mention a PSD file?
Translate
neirmourao
Participating Frequently
May 6, 2025 6:53 PM UTC

keep the size of shapes after re-mention the object

Translate
Inspiring
Apr 2, 2025 10:29 AM UTC

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?

Translate
neirmourao
Participating Frequently
Apr 2, 2025 11:25 AM UTC

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

Translate
Inspiring
Apr 2, 2025 1:36 PM UTC

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

Translate