{"id":280,"date":"2009-07-08T01:11:29","date_gmt":"2009-07-07T23:11:29","guid":{"rendered":"http:\/\/www.phreekz.de\/wordpress\/?p=280"},"modified":"2010-01-23T00:53:32","modified_gmt":"2010-01-22T22:53:32","slug":"photoshop-scripting-ii-getcolor","status":"publish","type":"post","link":"https:\/\/www.phreekz.de\/wordpress\/2009\/07\/photoshop-scripting-ii-getcolor\/","title":{"rendered":"Photoshop Scripting II &#8211; automatisches Keying"},"content":{"rendered":"<p>Diese Frage wird recht oft gestellt : Das automatische Freistellen mehrerer Bilder\/Objekte.  Also, hier das zugeh\u00f6rige Script, welches einfach nur den Farbwert an Pixelstelle 10\/10 ausliest und in einer Javascript-Alert-Box anzeigt.<\/p>\n<p><span style=\"color: #3366ff;\"><strong>getColor.jsx<\/strong><\/span><\/p>\n<pre language=\"javascript\">#target photoshop\r\nvar docAktuell = app.activeDocument;<\/code>\r\n\r\nvar pixelLoc = [UnitValue(\"10 pixels\") , UnitValue(\"10 pixels\")];\r\nvar colorSamplerRef = docAktuell.colorSamplers.add(pixelLoc);\r\nvar currentColor = colorSamplerRef.color;\r\n\r\nvar redVal = Math.round(currentColor.rgb.red);\r\nvar greenVal = Math.round(currentColor.rgb.green);\r\nvar blueVal = Math.round(currentColor.rgb.blue);\r\n\r\nalert(\"Pixel [10, 10] = (\" + redVal + \", \" + greenVal + \", \" + blueVal + \")\");\r\n\r\n<\/pre>\n<p>Scripts werden grunds\u00e4tzlich in <span style=\"color: #339966;\">.\/Photoshop\/Presets\/Scripts\/<\/span> abgelegt und sind dann in Photoshop unter Script erreichbar. \u00dcbrigens, es gibt ein tolles Forum daf\u00fcr :<a href=\"http:\/\/www.ps-scripts.com\/bb\/index.php\"> http:\/\/www.ps-scripts.com\/bb\/index.php<\/a> &#8211; Leider ist da nicht soviel los, Scripting ist halt nicht Jedermanns Sache.<\/p>\n<p>Hier also eine Minimalversion eines Photoshopscripts, dass in einer Datei 4 Selections in den Ecken nimmt, per Similar eine Keyingauswahl erstellt und diese in einer Maske speichert.<\/p>\n<p><span style=\"color: #3366ff;\"><strong>AutoKeyer.jsx<\/strong><\/span><\/p>\n<pre language=\"javascript\">#target photoshop\r\nvar docAktuell = app.activeDocument;\r\nvar maxX = docAktuell.width;\r\nvar maxY = docAktuell.height;<\/code>\r\n\r\n\/\/change backgroundlayer to worklayer\r\nif(docAktuell.layers[0].isBackgroundLayer==true){\r\ndocAktuell.layers[0].isBackgroundLayer=false;\r\n}\r\n\r\n\/\/ makeLayerMask function - done by Paul Riggott\r\n\/\/ http:\/\/forums.adobe.com\/thread\/290125\r\nfunction makeLayerMask(maskType) {\r\nif( maskType == undefined) maskType = 'RvlS' ; \/\/from selection\r\nvar desc140 = new ActionDescriptor();\r\ndesc140.putClass( charIDToTypeID('Nw  '), charIDToTypeID('Chnl') );\r\nvar ref51 = new ActionReference();\r\nref51.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );\r\ndesc140.putReference( charIDToTypeID('At  '), ref51 );\r\ndesc140.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('UsrM'), charIDToTypeID(maskType) );\r\nexecuteAction( charIDToTypeID('Mk  '), desc140, DialogModes.NO );\r\n}\r\n\r\n\/\/ change Rulerunits to px\r\nvar strtRulerUnits = app.preferences.rulerUnits;\r\napp.preferences.rulerUnits = Units.PIXELS;\r\n\r\n\/\/ 4 Corner rectangled Selections\r\ndocAktuell.selection.select(new Array (new Array(10,10),new Array(20,10), new Array(20,20), new Array(10,20)),SelectionType.REPLACE, 1, false);\r\ndocAktuell.selection.select(new Array (new Array(maxX-10,10),new Array(maxX-20,10), new Array(maxX-20,20), new Array(maxX-10,20)),SelectionType.EXTEND, 1, false);\r\ndocAktuell.selection.select(new Array (new Array(maxX-10,maxY-10),new Array(maxX-20,maxY-10), new Array(maxX-20,maxY-20), new Array(maxX-10,maxY-20)),SelectionType.EXTEND, 1, false);\r\ndocAktuell.selection.select(new Array (new Array(10,maxY-10),new Array(20,maxY-10), new Array(20,maxY-20), new Array(10,maxY-20)),SelectionType.EXTEND, 1, false);\r\n\r\n\/\/ Grab all pix similar to the selection\r\ndocAktuell.selection.similar(60,10);\r\n\r\n\/\/ change the selection a bit\r\nvar Selected = app.activeDocument.selection;\r\nSelected.expand( 0.2 );\r\n\/\/Selected.contract( 5 );\r\nSelected.feather( 0.2 );\r\n\r\n\/\/make a mask from it\r\nmakeLayerMask('HdSl');\r\n\r\n\/\/done ! thx by phreekz.chmee\r\n<\/pre>\n<p>Wieder mal die wichtige Info, dass keine Fehler abgefangen werden. Ich habe das Script mal mit <a href=\"http:\/\/cuvideoedit.com\/resources\/Sadie%20and%20green%20sceen.png\">diesem Bild<\/a> ausprobiert, mit <a href=\"http:\/\/images.digitalmedianet.com\/2005\/Week_14\/v0vw2fh3\/story\/raw1_250.jpg\">Diesem<\/a> und auch mit diesem <a href=\"http:\/\/www.moderntex.de\/shop_cfg\/Fotostudio\/gruen3x3.jpg\">Hier<\/a> . Sieht erstmal gut aus. Im Script sind die Variablen recht gut einsehbar, zB im Similar Bereich die Werte f\u00fcr Toleranz (60) und Antialiasing (10), danach auch noch Variablen, um die Selektion zu verbessern, Expand und Feather.<\/p>\n<p>Wenn man am Scripting Gefallen findet, sollte man mit diesem  <a href=\"http:\/\/photoshoptutorials.ws\/photoshop-tutorials\/technical\/manipulate-an-image-with-scripting.html\">Tutorial<\/a> weitermachen.<\/p>\n<p>mfg chmee<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Diese Frage wird recht oft gestellt : Das automatische Freistellen mehrerer Bilder\/Objekte. Also, hier das zugeh\u00f6rige Script, welches einfach nur den Farbwert an Pixelstelle 10\/10 ausliest und in einer Javascript-Alert-Box anzeigt. getColor.jsx #target photoshop var docAktuell = app.activeDocument; var pixelLoc = [UnitValue(&#8222;10 pixels&#8220;) , UnitValue(&#8222;10 pixels&#8220;)]; var colorSamplerRef = docAktuell.colorSamplers.add(pixelLoc); var currentColor = colorSamplerRef.color; var&hellip; <a class=\"more-link\" href=\"https:\/\/www.phreekz.de\/wordpress\/2009\/07\/photoshop-scripting-ii-getcolor\/\"><span class=\"screen-reader-text\">Photoshop Scripting II &#8211; automatisches Keying<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[137,7],"tags":[135,110,131,128,132,134,136,133,126,127],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-foto-ebb","category-video-graphics","tag-batch","tag-coding","tag-getcolor","tag-jsx","tag-key","tag-keying","tag-layermask","tag-mask","tag-photoshop","tag-scripting","entry"],"_links":{"self":[{"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":18,"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":282,"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/posts\/280\/revisions\/282"}],"wp:attachment":[{"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phreekz.de\/wordpress\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}