Looking for scripter

I'm wildife biology student and I'm using Adobe Photoshop to quantify color of wild animals. I'm looking for someone who can help me to adjust a java script.
The script automatizes random point selection in an image and gives an average color of the points.
I need the script to do two more things for me:
1. Save the RGB values from the random points into a spreadsheet so I can calculate stadard error OR provide the error along with the average RGB.
2. Randomly select points in a highlighted area of the photo (now it randomly selects points in the whole image, but I need it to select just from the animal (not the background).
If you know how to add either of these to the script, please let me know.
Thank you,
Marketa Zimova

Here is another version. It puts a stroke around the selection so it is easier to see. You might want to edit the color.
And yes you can include my name in the acknowledgement section if you wish.
// script expect  an open single layer document in RGB mode with a selection of the area to sample.
// the csv file is written to the desktop and the script will overwrite an existing samples.csv
main();
function main(){
     if( app.documents == 0 ) {
          alert("No image to process");
          return;
     var doc = app.activeDocument;
     if( doc.mode != DocumentMode.RGB ){
          alert("Image must be in RGB mode to sample");
          return;
     if( !hasSelection( doc ) ){
          alert("Please make a selection of target animal\rbefore running script");
          return;
     var numberOfSamples = Number(prompt("How many selections should be made?",10));
     if(  numberOfSamples == NaN )  numberOfSamples = 1;
     var sampleSize = Number(prompt("What size should each selection be?(NxN px)", 3));
     if( sampleSize == NaN ) sampleSize = 3;
     var originalLayer = doc.activeLayer;// make reference to current layer
     executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );// dupe selection to new layer
     var sampleLayer = doc.activeLayer;// make reference to that new layer
     originalLayer.visible = false;// turn off original layer
     var samples = [];// make array to hold samples
     var bounds = sampleLayer.bounds;
     var layerX = bounds[0].as('px');
     var layerY = bounds[0].as('px');
     var layerWidth = bounds[2].as('px') - bounds[0].as('px');
     var layerHeight = bounds[3].as('px') - bounds[1].as('px');
     // make requested number of samples
     var s = 0;
     while(  s < numberOfSamples ){
          var sX = randomRange( layerX, layerX + layerWidth );
          var sY = randomRange( layerY, layerY + layerHeight );
          var cs = doc.colorSamplers.add( [ new UnitValue( sX, 'px' ), new UnitValue( sY, 'px' ) ] );
          var sample = getSelectionColor( 0, sampleSize );
          if( undefined != sample ){
               samples.push( sample );
               s++;
          cs.remove();
     var sampleFile = new File('~/Desktop/samples.csv');
     sampleFile.open('w');
     sampleFile.writeln('red,green,blue');
     for( var s = 0; s< samples.length;s++ ){
          sampleFile.writeln( samples[s].rgb.red+','+samples[s].rgb.green+','+samples[s].rgb.blue );
     sampleFile.close();
     function randomRange( minVal, maxVal ){
          return minVal+Math.floor(Math.random()*( maxVal-minVal ));
     // Function: hasSelection
     // Description: Detremines if there is a selection
     // Usage: alert(hasSelection())
     // Input:
     // Return:  true or false
     // Dependencies:
      function hasSelection(doc) {
          var res = false;
          var as = doc.activeHistoryState;
          doc.selection.deselect();
          if (as != doc.activeHistoryState) {
               res = true;
               doc.activeHistoryState = as;
          return res;
     // adapted from scirpt by jugenjury at adobefourms
     function getSelectionColor( s, A ){
          var origRulerUnits = app.preferences.rulerUnits;
          app.preferences.rulerUnits = Units.PIXELS;
          try{
               if ( undefined == s ) { s=0; }
               if ( undefined == A ) { A=1; }
               var CP = app.activeDocument.colorSamplers;
               var sampleSize = A;
               var r=((A-1)/2);
               var x=Math.round(CP[s].position[0]-r);
               var y=Math.round(CP[s].position[1]-r);
               activeDocument.selection.select([[x, y], [x+sampleSize, y], [x+sampleSize, y+sampleSize], [x, y+sampleSize]], SelectionType.REPLACE, 0, false);
               activeDocument.activeLayer.applyAverage();
               var re = RegExp( '[123456789]' );
               var sColor = new SolidColor();
               if ( activeDocument.mode == DocumentMode.GRAYSCALE ) {
                    var gv = re.exec(activeDocument.channels[0].histogram.toString() ).index/2;
                    sColor.gray.gray = 100 * (gv/255);
               if ( activeDocument.mode == DocumentMode.RGB ) {
                    sColor.rgb.red = re.exec(activeDocument.channels[0].histogram.toString() ).index/2;
                    sColor.rgb.green = re.exec( activeDocument.channels[1].histogram.toString() ).index/2;
                    sColor.rgb.blue = re.exec( activeDocument.channels[2].histogram.toString() ).index/2;
               if ( activeDocument.mode == DocumentMode.LAB ) {
                    var lv = re.exec(activeDocument.channels[0].histogram.toString() ).index/2;
                    sColor.lab.l = 100 * ( lv/255 );
                    sColor.lab.a = ( re.exec( activeDocument.channels[1].histogram.toString() ).index/2 ) - 128;
                    sColor.lab.b = ( re.exec( activeDocument.channels[2].histogram.toString() ).index/2 ) -128;
               if ( activeDocument.mode == DocumentMode.CMYK ) {
                    var cv = re.exec(activeDocument.channels[0].histogram.toString() ).index/2;
                    sColor.cmyk.cyan = 100 * (1-(cv/255));
                    cv = re.exec(activeDocument.channels[1].histogram.toString() ).index/2;
                    sColor.cmyk.magenta = 100 * (1-(cv/255));
                    cv = re.exec(activeDocument.channels[2].histogram.toString() ).index/2;
                    sColor.cmyk.yellow = 100* (1-(cv/255));
                    cv = re.exec(activeDocument.channels[3].histogram.toString() ).index/2;
                    sColor.cmyk.black = 100 * (1-(cv/255));
               executeAction( charIDToTypeID('undo'), undefined, DialogModes.NO );
               executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );// dupe selection to new layer
               applyInsideStroke();
               app.refresh();
               var keep = confirm("Sample at px "+sX+','+sY+ ' is R:'+sColor.rgb.red+', G:'+sColor.rgb.green+', B:'+sColor.rgb.blue+'.\rKeep?',true);
               app.activeDocument.activeLayer.remove();
               activeDocument.selection.deselect();
               if( keep == true )return sColor;
               app.preferences.rulerUnits = origRulerUnits;
          }catch(e){
               app.preferences.rulerUnits = origRulerUnits;
     function applyInsideStroke( sColor ) {
          var sColor = new SolidColor;
          sColor.rgb.hexValue = '6dfe02';// edit stroke color here
          var desc = new ActionDescriptor();
               var ref = new ActionReference();
               ref.putProperty( charIDToTypeID('Prpr'), charIDToTypeID('Lefx') );
               ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
          desc.putReference( charIDToTypeID('null'), ref );
               var effectDesc = new ActionDescriptor();
               effectDesc.putUnitDouble( charIDToTypeID('Scl '), charIDToTypeID('#Prc'), 100.000000 );
                    var strokeDesc = new ActionDescriptor();
                    strokeDesc.putBoolean( charIDToTypeID('enab'), true );
                    strokeDesc.putEnumerated( charIDToTypeID('Styl'), charIDToTypeID('FStl'), charIDToTypeID('InsF') );
                    strokeDesc.putEnumerated( charIDToTypeID('PntT'), charIDToTypeID('FrFl'), charIDToTypeID('SClr') );
                    strokeDesc.putEnumerated( charIDToTypeID('Md  '), charIDToTypeID('BlnM'), charIDToTypeID('Nrml') );
                    strokeDesc.putUnitDouble( charIDToTypeID('Opct'), charIDToTypeID('#Prc'), 100.000000 );
                    strokeDesc.putUnitDouble( charIDToTypeID('Sz  '), charIDToTypeID('#Pxl'), 2.000000 );
                         var colorDesc = new ActionDescriptor();
                         colorDesc.putDouble( charIDToTypeID('Rd  '), sColor.rgb.red );
                         colorDesc.putDouble( charIDToTypeID('Grn '), sColor.rgb.green );
                         colorDesc.putDouble( charIDToTypeID('Bl  '), sColor.rgb.blue );
                    strokeDesc.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), colorDesc );
               effectDesc.putObject( charIDToTypeID('FrFX'), charIDToTypeID('FrFX'), strokeDesc );
          desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lefx'), effectDesc );
          executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

Similar Messages

  • Looking for Script Exchange-2007: Import-Mailbox Calendar Folder on multiple mailboxes {Distribution Group}

    Hi,
    I'm looking for a PowerShell script which will import a Calendar events into student's mailbox (Calendar). Those students are located in a distribution group and I would like to target the distribution group; I'm trying to simulate what I want to achieve
    in the below code example, I would appreciate if anyone jump in and advise.
    $Users = Import-Csv C:\users.csv | ForEach-Object{Get-DistributionGroup -Identity SC-1213} | Import-Mailbox -Identity $Users -PSTFolderPath c:\Calendar.pst -IncludeFolders '\Calendar' -StartDate -EndDate
    Much appreciated..
    Hussain

    The logic doesn't work unless you are using StartDate and EndDate for the period when you change the item.  As I said above, StartDate and EndDate are not the times when the meeting starts and ends - they are the times that the item was either added
    or modified in the mailbox.  Your filter was trying to pull items that were in the future.
    And as I also said above, if you import a modified item, the original is
    not going to be updated.  You will have a duplicate meeting
    on the calendar.  You would have to remove the original
    and import the updated item if this was how you wished to manage the updates.  This is not nearly as effective as
    sending meeting requests and updating those meetings.
    For example, if we do things the way you are doing them, and we add a "Student Appreciation Bonfire" meeting to the calendar for April 12 at "The Quad", we would do the following:
    On February 1, you get information for the meeting that needs to be imported
    You create this new meeting in the PST calendar - "Student Appreciation Bonfire"; Date April 12, start 8:00 AM, end 12:00 noon; Location The Quad
    You import the PST into everyone's calendar
    You receive a note on March 12 saying the venue has changed to The River Beach, so you update this meeting in your PST
    Since there are other calendar items in the PST, you import the update using StartDate of March 12 and EndDate of March 13 - the date that you changed the item, not the date the item occurs
    At this point, all users have two meetings on their calendar - the original and the update
    If, instead of doing it this way, you create a Student Actvities Calendar mailbox, you would handle it this way:
    On February 1, you get information for the meeting that needs to be imported
    You create this new meeting in the Corporate calendar - "Student Appreciation Bonfire"; Date April 12, start 8:00 AM, end 12:00 noon; Location The Quad
    You invite everyone to the meeting
    You receive a note on March 12 saying the venue has changed to The River Beach, so you update this meeting in that calendar and send out the update
    At this point, all users have only the one meeting on their calendar - the update
    Using the PST as the source for the meetings would work only for items that
    will not be changed - holidays are a good example.

  • Please help! Looking for script to insert current date on page.

    I currently use a Dreamweaver Extension that lets you insert
    current date and time on your web page.
    The problem is, I don't know Javascript and cannot edit the
    Javascript codes to "remove the time"
    I only need the current date that will change every day.
    Do you know where I can get this script, I goggled and got
    several but I'm looking for something authentic.
    Also is it possible to have your page validate when you use
    Javascript embedded in your HTML?
    Thanks everyone,
    Patrick

    quote:
    Originally posted by:
    Newsgroup User
    Webethics wrote:
    > The problem is, I don't know Javascript and cannot edit
    the Javascript codes
    > to "remove the time"
    > I only need the current date that will change every day.
    JavaScript generates the date by using the clock on the
    computer of each
    visitor to your site. If a visitor's clock has the wrong
    date, your site
    will also display the wrong date.
    > Do you know where I can get this script, I goggled and
    got several but I'm
    > looking for something authentic.
    I don't know what you mean by "authentic". Date generation in
    JavaScript
    is one of the most basic features of the language, so if it
    works, it's
    "authentic".
    > Also is it possible to have your page validate when you
    use Javascript
    > embedded in your HTML?
    Yes, but you shouldn't embed JavaScript in XHTML.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/
    So mr. Powers are there people that use Javascript Date in
    their page?
    Would you recommend it?
    I could use PHP but I don't know PHP,
    How do I come up with the string in this format, say,
    Wednesday, October 29th, 2008 that will change to a new day
    according to the server time and date.
    Thanks so much for your help and I have two of your books! I
    will be taking PHP classes in December.
    Patrick

  • Looking for script to auto resize images

    I have a commerce site and we have 3 sizes of images thumb
    nail, standard
    and fullsize. Ideally I'd like to maintain just one image
    folder so I don't
    have to keep synching and batch resizing.
    I'm looking for a script that would resample/resize images on
    the fly so I
    only have to maintain one directory. Does anyone know of such
    a script? It
    doesn't have to be free.
    Thanks

    .oO(robbie)
    >I have a commerce site and we have 3 sizes of images
    thumb nail, standard
    >and fullsize. Ideally I'd like to maintain just one image
    folder so I don't
    >have to keep synching and batch resizing.
    >
    >I'm looking for a script that would resample/resize
    images on the fly so I
    >only have to maintain one directory. Does anyone know of
    such a script? It
    >doesn't have to be free.
    What language? With PHP for example it's quite easy using the
    GD
    functions.
    Another way would be to use an external software. I prefer
    Paint Shop
    Pro for all image-related stuff. Things like creation of
    thumbnails in
    different sizes can easily be automated by using its own
    scripting
    language (based on Python).
    Micha

  • Looking for Scripts that Replaces Text and Master Pages (Batch Missing Files and PDFs)

    I have just found the Script Library panel in FM 10. (Always used InDesign before.)
    I'm up to replace a text string and two master pages in 100+ documents. Tried to google for some nice solutions to make this automatically but cannot find any scripts/macros to FM at all.
    Do you have som tip where to find such scripts/macros?
    To facilitate my work I also look for a batch script that automatically updates the image pathes in each framemaker file (image folder has been renamed).
    And at a last FrameMaker -> PDF Batch converter.

    100 is a small enough number that no time may be saved writing a script (assuming none exist for the purpose).
    I'd be tempted to ...
    Create a sourcing file that has the new MPs needed (and safe versions of MPs "Left" and "Right")
    Create a new Book file.
    Add to it all 100 of the files needing update (this is the only tedious part).
    Use Find/Replace from the Book menu to fix the text string.
    Select all book component files:
    File > Import > Formats
    Import from Document [MPsourcefilename.fm]
    [Deselect All]
    [*] Page Layouts
    [Import]

  • Looking for script - Quarantine policy reporting

    I'm looking for a way(script or CLI) to gather percentage information for Quarantine policy's and dump it to a ".csv" or ".txt" file.
    What I want is to collect the percentage of quarantined messages per policy.
    Thanks for your help in advance,

    jgarry wrote:
    [This one?|http://www.petefinnigan.com/find_all_privs.sql]
    That would be the one!
    Thanks.

  • UCCX - Looking for Script to forward the call

    attached

    OK, then it's relatively easy. First, let's create CSQ's per site. For instance, there will be a CSQ named "SiteA", "SiteB", "SiteN" etc. Next, we can create a script that takes a look at the caller's ANI (you can easily get that information using the Get Call Contact Info step). Based the ANI, we will take a look at the number of the agents available at the preferred site (using the Get Reporting Stats step). If it's not 0, we can go and route the call. If it's 0, then we can get the number of the available agents at the next preferred site and again, the next preferred site, until we get a site with at least one available agent.
    G.

  • Looking for script that will connect product and shopping cart

    I'm looking where I can find the script to make the product price or any other specifacations work with the shopping cart. Does anybody know where I can find this script at online?
    Thanks
    Bobby

    I'm looking where I can find the script to make the product price or any other specifacations work with the shopping cart. Does anybody know where I can find this script at online?
    Thanks
    Bobby

  • Looking for Scripts that Replaces Text and Master Pages

    I have just found the Script Library panel in FM 10. (Always used InDesign before.)
    I'm up to replace a text string and two master pages in 100+ documents. Tried to google for some nice solutions to make this automatically but cannot find any scripts/macros to FM at all.
    Do you have som tip where to find such script/macro?

    100 is a small enough number that no time may be saved writing a script (assuming none exist for the purpose).
    I'd be tempted to ...
    Create a sourcing file that has the new MPs needed (and safe versions of MPs "Left" and "Right")
    Create a new Book file.
    Add to it all 100 of the files needing update (this is the only tedious part).
    Use Find/Replace from the Book menu to fix the text string.
    Select all book component files:
    File > Import > Formats
    Import from Document [MPsourcefilename.fm]
    [Deselect All]
    [*] Page Layouts
    [Import]

  • Looking for scripts

    any idea how can I get the tables and data Oracle Education use for their 8iDA training class.
    Am revising for 8i, and cannot do the practises in Oracle 8i study guide.
    tks.
    Singapore

    Hi !
    A short search on Google should reveal a lot of script. However the thing you ask is somewhat strange. First of all I'm puzzeled by the wish for a regular offline backup of a RAC env. The intention of RAC is to stay online forever. Furthermore an offline backup id something that happens solely on the filesystem. Therefore the support of EM is limited, as the focus lies on using RMAN that will give you a lot of possibilities to create online backups.
    cu
    Andreas

  • Looking for script that expands and closes flash window

    You've seen a web site were the flash expands with an option to close. Doe's anybody know where I can learn that script?
    Thanks

    Try fscommand:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/package.html#fscomm and()

  • I blog on TypePad using Word 2007 and documents freeze when I'm looking at them in Windows explorer; why do I get the error message that Mozilla is looking for a script?

    I have now had two error messages - the first one looked for this script: Script: resource://gre/modules/XPCOMUtils.jsm:258. The second one (today) looked for Script: resource://gre/components/nsPrompter.js:68.
    I have reset my word template, also reset word registry for data and options (as per Microsoft's help pages) for both those 'fixes' there was an initial improvement, but the problem happened again after I reposted on my blog today and then went to Windows explorer to view my files. It seems to 'seize' as I select a file, so that the preview does not appear (for up to 15-20mins).
    I see on the internet using the second script as a search just now that one other has had a similar problem and one also since Mozilla 4 upgrade. My problems have also been pretty much since I upgraded.
    It happens (apart from my fixes) every time I go to look at a word document via Windows explorer. Excel files are less affected.
    One web suggestion is to clear the cache, but I am hesitant to lose all my passwords unless I have to.

    I still have the problem although I uninstalled Mozilla (clearing the cache didn't work and neither did Word diagnostics), so have ended up thinking it could be Norton (the manual update worked x1) or Windows. Today I found an answer: disable the preview pane in Windows Explorer - there's a history of problems with this view.

  • Looking for RT61 scripts? [Solved Maybe!]

    Following this in wiki....
    http://wiki.archlinux.org/index.php/RT61_Wireless
    looking for scripts?
    Anyone know where I can find them?
    Edit Just looking at wicd...will read install notes looks like what I need!

    My setup is very similar to tomk's - minimal Arch install, LTS kernel, managed over SSH. It used to be my compiling setup (until my more powerful laptop came along), but it does a mighty fine job as an MPD server (connected to my stereo), torrent server and NFS file server (for my HTPC). Also runs a small webserver (ruTorrent frontend) but the webserver is starting to be employed as an FTP replacement - so I can access my OpenWrt builds from the LAN, and as an Arch package repo.
    I back up like once a month over eS-ATA. 1 TB & 2 TB HD's in my server, identical ones in my eS-ATA disks. 2 GB of RAM, but I could probably make do with 512 - on i686, that is. I would take out what you don't need, 4 GB sounds like overkill for just about any server unless you're gonna virtualise and stuff, and you shave a few Watts off your idle usage.
    RAID is not a backup, the best backups are off-line and (ideally) off-site. My eS-ATA disks are in another room, so far for off-site .
    Last edited by .:B:. (2011-09-12 22:33:11)

  • Encoding error occurs using parameter "default path for scripts"

    Hello,
    assume we have a script "/home/artur/tymczasowe/test.sql". I can execute it using SQL Developer by:
    @/home/artur/tymczasowe/test.sql
    Everything works as expected.
    Then I set parameter "Tools - Preferences - Database - Worksheet - Default path to look for script" to "/home/artur/tymczasowe" and executed:
    @test.sql
    This time national characters has been lost, everyone replaced with "�".
    The script content:
    --create table a(enc varchar2(8), data varchar2(255));
    delete from a;
    insert into a(enc, data) values ('cp1250', 'zażółć gęślą jaźń');
    commit;
    Operating system is Debian Squeeze amd64, Developer version is 3.1.07, Build MAIN-07.42. This problem occurs using previous, 3.0.* versions too.

    Hi user633485
    Logged bug:
    Bug 13779254 - ENCODING DEFAULTS TO NATIVE RATHER THAN IDE SETTING USING DEFAULT PATH
    -Turloch
    SQLDeveloper Team

  • Default path for scripts within SQL Developer version 3.2.20.09.87

    I have SQL Developer version 3.2.20.09.87 and needed to know if the 'Set default path to look for scripts' be a UNC path?
    Thanks

    I hadn't tried it but now I did and it worked.
    I also tried setting the Utilities Export default file location to a UNC path and I was able to set it but when I try to go to it via the 'browse' button, it doesnt go to it. It does, however, use it when I export.
    Also when I do File > Open, I'm not able to navigate to UNC paths via the 'Home' or 'Desktop' buttons on the left hand side of the window and am not able to navigate to a network location from the 'Locations' box.
    Any ideas? I am on Windows 7.
    Thanks

Maybe you are looking for