Question
I need a script to create a new file with double the dimensions and 144dpi in photoshop 2023
I tried to use AI to create a script to create a new 144 dpi file in Photoshop 2023 from the clipboard image, with twice the dimensions. It generated the following code.
// This is a Photoshop script that creates a new document from the clipboard with double the dimensions and 144 dpi resolution
// Save this file as a .jsx extension and place it in the Photoshop 2023/Presets/Scripts folder
// Restart Photoshop and run the script from File > Scripts > Create New File From Clipboard
// Check if there is something in the clipboard
if (app.clipboard.hasData()) {
// Get the clipboard data as a bitmap
var clipboardData = app.clipboard.getData("bitmap");
// Get the width and height of the bitmap in pixels
var width = clipboardData.width;
var height = clipboardData.height;
// Double the width and height
width *= 2;
height *= 2;
// Create a new document with the doubled dimensions and 144 dpi resolution
var newDoc = app.documents.add(width, height, 144);
// Paste the clipboard data into the new document
newDoc.paste();
// Resize the pasted layer to fit the document
newDoc.activeLayer.resize(200,200);
// Rename the new document
newDoc.name = "New File From Clipboard";
} else {
// Alert the user that there is nothing in the clipboard to paste
alert("There is nothing in the clipboard to paste.");
}
It fails, gives me the following error.
Any idea to make it work? Apparently app.clipboard.hasData() is not finding the clipboard's data.
