Recoginize file type with expressions?
by Mats Jacobsson
on
Jun 29, 2009 at 2:46:01 pm
Hi!
Is there an expression to recognize if the source file to a layer is vectorized or pixelated? It would also work if the expression just could detect the filetype of the layer.
Re: Recoginize file type with expressions? by Dan Ebberts on Jun 29, 2009 at 2:57:28 pm
Only if you can deduce it from the name of the source file (probably by looking at the file extension). Here's an example that should detect PSD files (not tested, so watch out for typos):
mySplit = thisLayer.source.name.split["."]; // split source name at "." characters
myExtension = mySplit[mySplit.length - 1]; // get everything to the right of the last "."
if (myExtension.toLowerCase() == "psd"){
// it's a psd file
}else{
// it's not a psd file
}
Re: Recoginize file type with expressions? by Mats Jacobsson on Jun 30, 2009 at 7:02:14 am
Wow, thanks a lot! Just what I needed.
There was one small typo however, it should be (".") instead of ["."] to work:
mySplit = thisLayer.source.name.split("."); // split source name at "." characters
myExtension = mySplit[mySplit.length - 1]; // get everything to the right of the last "."
if (myExtension.toLowerCase() == "psd"){
// it's a psd file
}else{
// it's not a psd file
}