Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

condition with pick color

New Here ,
Nov 13, 2009 Nov 13, 2009

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

TOPICS
Actions and scripting
870
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Nov 14, 2009 Nov 14, 2009

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,
...
Translate
Adobe
Guru ,
Nov 13, 2009 Nov 13, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 13, 2009 Nov 13, 2009

Which version of Photoshop are you using? -> CS2, also have CS4

Where is the black line? At bottom 15-30px tall or 15-30px from bottom? -> on screen

How thick is the black line? -> on screen

Is it on it's own layer? If not there do you want a layer? -> i use jpg files without layers

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 13, 2009 Nov 13, 2009

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');
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2009 Nov 14, 2009

it's really work, but some images have troubles(look screen)

Can we check just little area of bottom line?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 14, 2009 Nov 14, 2009

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');
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 14, 2009 Nov 14, 2009

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');
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2009 Nov 14, 2009
LATEST

Thank you my friends, it's all really work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines