Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Apr 01, 2025 Apr 01, 2025

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



TOPICS
Actions and scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Enthusiast ,
Apr 02, 2025 Apr 02, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2025 Apr 02, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 02, 2025 Apr 02, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2025 Apr 02, 2025

I made a script for the fonts with gpt chat, but the lines and arrows don't work in the code. Can you help with the script for them?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 02, 2025 Apr 02, 2025

Post a Psd file and we'll see if we can do something, I don't guarantee the result, It's just a test.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 02, 2025 Apr 02, 2025


Ok! This file is 2654x2654px 300dpi, and I need to scale it to 1500x1500px 300dpi, but keep the lines, arrows and fonts with the same size (example: the lines are 1px high, the black arrows have 1.5px stroke, 10px width and 10px height, the red arrows are 10px high and 10px wide too. The fonts are in 6pt and also in 4.7pt in the part diameters. But I got the fonts from the script. I really appreciate your help in advance.

https://drive.google.com/file/d/1vtR4Mt5vySOttcWDDPXl78XeQPSaU9pE/view?usp=sharing 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 14, 2025 Apr 14, 2025

Hey, no rush at all, just wondering if you were able to work on the file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 14, 2025 Apr 14, 2025

Sorry, I've been busy with projects that are due lately and can't help you, if I get free I'll take a look.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2025 Apr 14, 2025
It's a little confusing, but are you trying to re-mention a PSD file?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 06, 2025 May 06, 2025

keep the size of shapes after re-mention the object

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 18, 2025 Apr 18, 2025

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

sorry.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 06, 2025 May 06, 2025

thanks anyway for your time 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 06, 2025 May 06, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2025 Aug 15, 2025
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines