Copy link to clipboard
Copied
Hello Everyone,
I have 3 files:
1. First file is a Smart Object from Camera Raw, meaning if I edit contents of it, Camera Raw will open
2. Second file is a normal Smart Object, when you edit contents it opens a new document with psb file.
3. Lastly, I have a normal rasterized layer.
I want a script that will edit contents only for the second image, maybe a function that will return true false if that is possible.
Requirements:
> i don't want to edit contents for the first image because i don't want the Camera Raw window will open.
> and I don't want to edit contents for the third image because it's impossible (rasterized layer).
Any ideas?
These are my 3 files:
1. First file is a Smart Object from Camera Raw, meaning if I Edit Contents of it, Camera Raw will open
2. Second file is a normal Smart Object, when you edit contents it opens a new document with psb file
3. Lastly, I have a rasterized layer
Copy link to clipboard
Copied
Ask r-bin if there is a way to find out what king of object a smart object layer has without opening it. He may know of a way.
Copy link to clipboard
Copied
r-bin​ JJ is right, this should be easy for you
Copy link to clipboard
Copied
var ext = smartobject_file_ext(activeDocument.activeLayer);
switch (ext)
{
case "psb":
case "psd":
alert(ext+"\n\nediting is posible");
break;
case "nef":
case "cr2":
case "crw":
case "raf":
case "orf":
case "mrw":
case "dcr":
case "mos":
case "raw":
case "pef":
case "srf":
case "dng":
case "x3f":
case "erf":
case "sr2":
case "kdc":
case "mfw":
case "mef":
case "arw":
case "nrw":
case "rw2":
case "rwl":
case "iiq":
case "3fr":
case "fff":
case "srw":
alert("raw file\n\nskip");
break;
case "error":
alert("not a smart object");
break;
default:
alert("unknown ext: " + ext + "\n\ncan try to edit");
break;
}
function smartobject_file_ext(layer)
{
try {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("smartObject"));
r.putIdentifier(stringIDToTypeID("layer"), layer.id);
var name = executeActionGet(r).getObjectValue(stringIDToTypeID("smartObject")).getString(stringIDToTypeID("fileReference"));
var n = name.lastIndexOf(".");
if (n < 0) return "";
return name.substr(n+1).toLowerCase();
}
catch (e) { return "error"; }
}
Copy link to clipboard
Copied
Thank r-bin his code get the ext and works well. Many placed image file types will open in Photoshop some like .svg and .ai will open in AI if you have it installed. You may want to add svg and ai the skip list. Also if the filetype is jpeg if you edit the jpeg and add layers you must flatten the document Photoshop will not save a layer document if the object was a flat jpeg. Photoshop will open a dialog asking it you want to save the layered document id you code a close and Save.
r-bin thank you ver much. I was able to fix a hole in my Batch Mockup Populating scripts when the scripts edit smart object option is used instead of the default replace content. Free Photoshop Photo Collage and Mockup Toolkit