-
1. Re: Detect if top line of a layer is empty or not?
Muppet Mark Jun 21, 2013 6:00 AM (in response to Mattmcquiff)I would make a selection of the area and try to copy it… PS will throw an error if it's empty…
I think their are better ways though…
-
2. Re: Detect if top line of a layer is empty or not?
pixxxel schubser Jun 21, 2013 10:51 AM (in response to Mattmcquiff)There are many possibilities. E.g. this Javascript works for the active layer:
var Bds = app.activeDocument.activeLayer.bounds; if (Bds[1] > 0) { alert (Bds[1] + " distance from above") } -
3. Re: Detect if top line of a layer is empty or not?
Michael L Hale Jun 21, 2013 11:01 AM (in response to Mattmcquiff)Depending on what you are trying to do you could use Document.trim(). That would remove transparent pixels from the top of images that have them and do nothing for the images that don't have transparent pixel at the top.
You could use scriptlistener to load then save the document transparency channel to an alpha channel then select the top row and get the histogram of that alpha channel.
There are other ways as well but they use a layer object so may not work correctly if the document has more than one layer.
Or do it the easy way and use Mark's suggestion. But again it tries to copy the activeLayer. Another layer may not be transparent at the top.
// select the area you want to test for transparency
try{
app.activeDocument.selection.copy();
}catch(e){
// deal with transparent pixels in selection
}
-
4. Re: Detect if top line of a layer is empty or not?
Muppet Mark Jun 22, 2013 3:05 AM (in response to Michael L Hale)tell application "Adobe Photoshop CS5"
activate
tell current document
set the current layer to the first layer
set w to width
select region {{0, 0}, {w, 0}, {w, 1}, {0, 1}}
try
copy
display dialog "Your selection has data!!!" giving up after 2
on error
display dialog "Your selection is empty!!!" giving up after 2
end try
end tell
end tell

