Copy link to clipboard
Copied
Hi guys, i newbie in scripting and need you help, i have create this structure, but i can't realize this on javascript:
- for example we have image 800x600(px) with absolutely black line in bottom(15-30px), but some image don't have this line, and i want create condition;
- if (black_line -> true) {some function} else {some function};
- (black_line -> true) i think we can realize this with color picking on bottom.
If you have some ideas please help.
Sorry for my bad english.
ps: Thanks
If you just want to check 10px X 10px bottom right
function hasBlackBottomRight(){
var doc = activeDocument;
var w = doc.width.as('px');
var h = doc.height.as('px');
var t = new Array( new UnitValue(w-10,'px'),new UnitValue(h-10,'px'));
var r = new Array( new UnitValue(w,'px'), new UnitValue(h-10,'px'));
var b = new Array( new UnitValue(w,'px'), new UnitValue(h,'px'));
var l = new Array( new UnitValue(w-10,'px'), new UnitValue(h,'px'));
doc.selection.select([t,r,b,...
Copy link to clipboard
Copied
A few questions,
Which version of Photoshop are you using?
Where is the black line? At bottom 15-30px tall or 15-30px from bottom?
How thick is the black line?
Is it on it's own layer? If not there do you want a layer?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
function hasBlackBottom( thickness ){
var doc = activeDocument;
var w = doc.width.as('px');
var h = doc.height.as('px');
var t = new Array( new UnitValue(0,'px'), new UnitValue(h-thickness,'px'));
var r = new Array( new UnitValue(w,'px'), new UnitValue(h-thickness,'px'));
var b = new Array( new UnitValue(w,'px'), new UnitValue(h,'px'));
var l = new Array( new UnitValue(0,'px'), new UnitValue(h,'px'));
doc.selection.select([t,r,b,l]);
return !!!doc.histogram.toString().match(/,[1-9]/g);
}
if( hasBlackBottom( 15 )){
// code to deal with black line at bottom;
alert('has black bar at bottom');
}else{
// code to deal with missing black line;
alert('No black bar at bottom');
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Here's a quick modifcation to Mike's code..
function hasBlackBottom( thickness ){
var doc = activeDocument;
var w = doc.width.as('px');
var h = doc.height.as('px');
var t = new Array( new UnitValue(w-50,'px'),new UnitValue(h-thickness,'px'));
var r = new Array( new UnitValue(w,'px'), new UnitValue(h-thickness,'px'));
var b = new Array( new UnitValue(w,'px'), new UnitValue(h,'px'));
var l = new Array( new UnitValue(w-50,'px'), new UnitValue(h,'px'));
doc.selection.select([t,r,b,l]);
return !!!doc.histogram.toString().match(/,[1-9]/g);
}
if( hasBlackBottom( 15 )){
// code to deal with black line at bottom;
alert('has black bar at bottom');
}else{
// code to deal with missing black line;
alert('No black bar at bottom');
}
Copy link to clipboard
Copied
If you just want to check 10px X 10px bottom right
function hasBlackBottomRight(){
var doc = activeDocument;
var w = doc.width.as('px');
var h = doc.height.as('px');
var t = new Array( new UnitValue(w-10,'px'),new UnitValue(h-10,'px'));
var r = new Array( new UnitValue(w,'px'), new UnitValue(h-10,'px'));
var b = new Array( new UnitValue(w,'px'), new UnitValue(h,'px'));
var l = new Array( new UnitValue(w-10,'px'), new UnitValue(h,'px'));
doc.selection.select([t,r,b,l]);
return !!!doc.histogram.toString().match(/,[1-9]/g);
}
if( hasBlackBottomRight()){
// code to deal with black line at bottom;
alert('All black at bottom right');
}else{
// code to deal with missing black line;
alert('Non black colors at bottom right');
}
Copy link to clipboard
Copied
Thank you my friends, it's all really work.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now