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.
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
...
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?
Copy link to clipboard
Copied
x,y is the coordinates.
Import the image with JSX Script (Javascript Code Script)
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.
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The second is cool, but how I import my image to my PSD?
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
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.
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?
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.
This solution is great to move it, but I need first to import the image..
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]));
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
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
Copy link to clipboard
Copied
Same error that say the duplicate command is not available.. 😕
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
How the problem was my image (PNG is not working I dont know why, but jpg works...)
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