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

transform layer of fixed size

Guest
Dec 19, 2010 Dec 19, 2010

Copy link to clipboard

Copied

Hi,
I would ask if it is possible to transform a layer, image, according to specified limits (upper left corner, lower right corner). My problem is that the script allows me to select any image and subsequently to me translates to a size that I could use it as a logo. I want to be transformed into each picture the same size and shape (even at the deformation).
Size width or height can I change with the values and awarded as a percentage, ie output size depends on input size. I hope you understand me. I attach you my script.

//transformacia loga na danu velkost
var id459 = charIDToTypeID( "Trnf" );
var desc92 = new ActionDescriptor();
var id460 = charIDToTypeID( "null" );
var ref37 = new ActionReference();
var id461 = charIDToTypeID( "Lyr " );
var id462 = charIDToTypeID( "Ordn" );
var id463 = charIDToTypeID( "Trgt" );
ref37.putEnumerated( id461, id462, id463 );
desc92.putReference( id460, ref37 );
var id464 = charIDToTypeID( "FTcs" );
var id465 = charIDToTypeID( "QCSt" );
var id466 = charIDToTypeID( "Qcsa" );
desc92.putEnumerated( id464, id465, id466 );
var id467 = charIDToTypeID( "Ofst" );
var desc93 = new ActionDescriptor();
var id468 = charIDToTypeID( "Hrzn" );
var id469 = charIDToTypeID( "#Rlt" );
desc93.putUnitDouble( id468, id469, 65.051841 );
var id470 = charIDToTypeID( "Vrtc" );
var id471 = charIDToTypeID( "#Rlt" );
desc93.putUnitDouble( id470, id471, -39.860197 );
var id472 = charIDToTypeID( "Ofst" );
desc92.putObject( id467, id472, desc93 );
var id473 = charIDToTypeID( "Wdth" );
var id474 = charIDToTypeID( "#Prc" );
desc92.putUnitDouble( id473, id474, 36.223685 );
var id475 = charIDToTypeID( "Hght" );
var id476 = charIDToTypeID( "#Prc" );
desc92.putUnitDouble( id475, id476, 36.223685 );
executeAction( id459, desc92, DialogModes.NO );

Thank you

TOPICS
Actions and scripting

Views

774

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Dec 20, 2010 Dec 20, 2010
I would ask if it is possible to transform a layer, image, according to specified limits (upper left corner, lower right corner)

I’m not sure I follow, do you mean the file’s upper left and lower right corners?

Then this might work, though this is probably a bit slower than ActionDescriptor-code.

var doc = app.activeDocument;

var layer = doc.activeLayer;

layer.translate(layer.bounds[0] * (-1), layer.bounds[1] * (-1));

layer.resize(doc.width / layer.bounds[2] * 100, doc.height / layer.bounds[3] * 100

...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 20, 2010 Dec 20, 2010

Copy link to clipboard

Copied

I would ask if it is possible to transform a layer, image, according to specified limits (upper left corner, lower right corner)

I’m not sure I follow, do you mean the file’s upper left and lower right corners?

Then this might work, though this is probably a bit slower than ActionDescriptor-code.

var doc = app.activeDocument;

var layer = doc.activeLayer;

layer.translate(layer.bounds[0] * (-1), layer.bounds[1] * (-1));

layer.resize(doc.width / layer.bounds[2] * 100, doc.height / layer.bounds[3] * 100, AnchorPosition.TOPLEFT);

Votes

Translate

Translate

Report

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
Valorous Hero ,
Dec 20, 2010 Dec 20, 2010

Copy link to clipboard

Copied

If you are wanting to resize the logo keeping its relative size for different sized documents this example might be better. The example is using a text layer, but will work for a normal layer.
http://www.ps-scripts.com/bb/viewtopic.php?f=9&t=3777&sid=7e09ee3a7302a503a60abb5b006bb2d5I have a script that will add Logo's/Text at relative sizes:
http://www.ps-scripts.com/bb/viewtopic.php?f=10&t=3409&sid=bc2418ca01e9dde62598a4ac2ef77f12
The last verion supports adding logo's/text, you could look at the code and see if it will help you.

Votes

Translate

Translate

Report

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
Guest
Dec 20, 2010 Dec 20, 2010

Copy link to clipboard

Copied

Just a pity that Photoshop solved with the transformation of fixed values and only work with the percent (if the option to switch between these modes). Thank you for both solutions.

Votes

Translate

Translate

Report

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 ,
Dec 20, 2010 Dec 20, 2010

Copy link to clipboard

Copied

LATEST

pali185 wrote:

Hi,
I would ask if it is possible to transform a layer, image, according to specified limits (upper left corner, lower right corner). My problem is that the script allows me to select any image and subsequently to me translates to a size that I could use it as a logo. I want to be transformed into each picture the same size and shape (even at the deformation).
Size width or height can I change with the values and awarded as a percentage, ie output size depends on input size. I hope you understand me.

I just can not understand the above. It sounds a bit like your trying to automate  placing a logo on different size images  adjusting the size of the logo to the image size. If this is what your trying to do. There is a sample action the uses a script to retain the original image size and add three watermarks to the image.  One a custom shape layer. One a text layer and one a color logo layer with transparency. Package link http://www.mouseprints.net/old/dpr/JJMacksCraftingActions.zip  example: http://www.mouseprints.net/old/dpr/WM900x600.jpg

JJMack

Votes

Translate

Translate

Report

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