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

How to import image in special x,y and resize it using jsx script

Community Beginner ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Hello,

 

I want to import one image with special y,x coordination and resize it using javascript script.

If someone have idea, im trying to find the solution but im not good in js.

 

Thanks you.

TOPICS
Actions and scripting

Views

2.0K

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 , Sep 15, 2020 Sep 15, 2020

Here's a script that will ask to open two files. then move the top layer to the first doc and close the second file. It will then resize to 50% (you can change that) and finally move it to x=5 and y=5

 

var mask = '*.*'
var file1 = File.openDialog ('Open primary file', mask, false);
var doc1 = open(file1);
var file2 = File.openDialog ('Open primary file', mask, false);
var doc2 = open(file2);

activeDocument = doc2;
var curLayer = doc2.layers[0];
curLayer.duplicate (doc1.layers[0], ElementPlacem
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

import image in special x,y   import one image with special y,x 

 

Before we can address  resize can you explain  special x,y   and  special y,x  ? And Import how?

image.png

 

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
Community Beginner ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

x,y is the coordinates.

Import the image with JSX Script (Javascript Code Script)

 

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 ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

Yes what is special about your x,y points. You can align an image layer to any pixel. Select the pixel and align the layer(s) to the selection. Resize the layer and align the image layer to the x,y point.

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
Community Expert ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

This may not be the best way, however, I would align to the canvas (i.e. upper left), then translate using the required pixel position.

 

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 ,
Sep 14, 2020 Sep 14, 2020

Copy link to clipboard

Copied

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

The second is cool, but how I import my image to my PSD?

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 ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Perhaps if you describe what you are trying to accomplish we can provide some guidance.

 

You do not need to try to use Photoshop terms  or x,y locations.  Simple describe what you are trying to create. What is your vision

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
Community Expert ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

I don't believe that you have provided that information.

 

 I don't think that you are importing as such, just using this as a general term.

 

Are you opening both files and copy+paste?

 

Are you duplicating layers from one to another?

 

Place linked or embedded?

 

Apply image?

 

How?

 

More info is required.

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 ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

I would copy the image into the new image, then size it, and finally use translate to move it to the xy position.

Is the image you want to import a single layer?

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

I have one image and I want to import new one into this first image then size it and then move it with xy position

 

- LayerOne = First Image

- LayerTwo = Second Image (Resize + xy position)

 

Actually my script in jsx open the first image, but i don't know the rest.

 

https://gist.githubusercontent.com/MarshySwamp/1ef7448b6bb22865ed7b7e1b8a4f521f/raw/c24ff74362de991e...

This solution is great to move it, but I need first to import the image..

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 ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Here's a script that will ask to open two files. then move the top layer to the first doc and close the second file. It will then resize to 50% (you can change that) and finally move it to x=5 and y=5

 

var mask = '*.*'
var file1 = File.openDialog ('Open primary file', mask, false);
var doc1 = open(file1);
var file2 = File.openDialog ('Open primary file', mask, false);
var doc2 = open(file2);

activeDocument = doc2;
var curLayer = doc2.layers[0];
curLayer.duplicate (doc1.layers[0], ElementPlacement.PLACEBEFORE);
doc2.close (SaveOptions.DONOTSAVECHANGES);
activeDocument = doc1
curLayer = doc1.layers[0];


curLayer.resize(50,50);

var xPrime = 5;
var yPrime =5;


curLayer.translate(xPrime - parseInt(curLayer.bounds[0]),yPrime - parseInt(curLayer.bounds[1]));

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Error: The duplicate command is not available.

 

 

 

/OPEN .PSD FILE
var file1 = Folder('C:/Users/Administrator/Desktop/PhotoshopImg/'+ psdFile +'.psd');
var doc1 = open(file1);

//OPEN TEST IMAGE
var file2 = Folder('C:/Users/Administrator/Desktop/PhotoshopImg/img_test.png');
var doc2 = open(file2);

activeDocument = doc2;
var curLayer = doc2.layers[0];
curLayer.duplicate (doc1.layers[0], ElementPlacement.PLACEBEFORE);

activeDocument = doc1

 

 

 

Here is my code 

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 ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Try this:

/OPEN .PSD FILE
var file1 = Folder('C:/Users/Administrator/Desktop/PhotoshopImg/'+ psdFile +'.psd');
var doc1 = open(file1);

//OPEN TEST IMAGE
var file2 = Folder('C:/Users/Administrator/Desktop/PhotoshopImg/img_test.png');
var doc2 = open(file2);

activeDocument = doc2;
var curLayer = doc2.layers[0];
activeLayer = curLayer;
curLayer.duplicate (doc1.layers[0], ElementPlacement.PLACEBEFORE);

activeDocument = doc1

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

Same error that say the duplicate command is not available.. 😕

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 ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

I'm having no problem running the script you posted. Can you post a screen shot of of PS after the script runs?

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

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 Beginner ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

LATEST

How the problem was my image (PNG is not working I dont know why, but jpg works...)

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 ,
Sep 15, 2020 Sep 15, 2020

Copy link to clipboard

Copied

A simple template could used with a script to populate both images.  A simple script can layout hundreds your image tiled over a canvas.  Templates are extremely easy to create. Scripts are not hard to use. There are many on the web there is no reason to reinvent the wheel. Making a better wheel would be a good project. With mockup templates you can add perspective distortion rotation etc.  It easy for a script to size position shape image etc with a good template.

 

 

Free Photoshop Photo Collage and Mockup Toolkit 

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