Can an action set the dimension of the crop and put in the center of the image?

Hi
running cs6 64bit under w7 64bit
can an action set the dimensions of the crop height & length and put the crop in the center of the image?
or should i need a script?
i mean for example i taken many photos about 20mp mega pixel
i would like to run a script or an action that set the height & length and set the crop in the center of the image
thanks

mantralightroom wrote:
i have cs6 but i haven't in the action option conditional actions
ps i tried to record a script to set the histogram channel RGB or Luminocity , but the script plugin doesn't record it and even the action can do it
you know cs6 starts with histogram in colors mode
I have a hard time with English even though it may native language.  I'm having some problem with what you wrote.
Yes cs6 does not have what Adobe calls conditional actions they put into CC.  That feature more or less an IF statement condition on some document attributes.  Like if document width is greater then document height play action landscape else play action portrait.   With CS6 you need to write one line script to use in actions.  Most of the utility scripts I wrote for use in actions are more complex then a simple if statement.
The way you record scripts is PS is be using Adobe Scriptlistener Plug-in when installed the plug-in records everything you do that can be recorded into two log files one in JavaScript and the other in VBS.  The code generated  works by passing parameters to Adobe Photoshop's Action Manager.  To make scripts toy need to extract the steps you need from one of the log files.    However some thing you can do in Photoshop can not be recorded. And while your right that the scriptlistener plug-in  does not record anything for setting the histograms to RGB channel or Luminosity  channel your wrong when you write the Action Recorder can do it.
However scripts can get the histograms channel data. I have never process a histogram in a script however there is a sample Photoshop Histogram in the Photoshop javascripting guide. That creates a text graph log.
// Function to activate all the channels according to the documents mode
// Takes a document reference for input
function TurnOnDocumentHistogramChannels(inDocument) {
    // see how many channels we need to activate
    var visibleChannelCount = 0
    // based on the mode of the document
    switch (inDocument.mode) {
        case DocumentMode.BITMAP:
        case DocumentMode.GRAYSCALE:
        case DocumentMode.INDEXEDCOLOR:
            visibleChannelCount = 1
            break;     
        case DocumentMode.DUOTONE:
            visibleChannelCount = 2
            break;
        case DocumentMode.RGB:
        case DocumentMode.LAB:
            visibleChannelCount = 3
            break;
        case DocumentMode.CMYK:
            visibleChannelCount = 4
            break;
        case DocumentMode.MULTICHANNEL:
        default:
            visibleChannelCount = inDocument.channels.length + 1
            break;
    // now get the channels to activate into a local array
    var aChannelArray = new Array()
    // index for the active channels array
    var aChannelIndex = 0
    for(var channelIndex = 0; channelIndex < inDocument.channels.length;channelIndex++) {
        if (channelIndex < visibleChannelCount) { aChannelArray[aChannelIndex++] = inDocument.channels[channelIndex] }
    // now activate them
    inDocument.activeChannels = aChannelArray
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// Set Adobe Photoshop CC to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
// if there are no documents open then try to open a sample file
if (app.documents.length == 0) { open(File(app.path + "/Samples/Fish.psd")) }
// get a reference to the working document
var docRef = app.activeDocument
// create the output file
// first figure out which kind of line feeds we need
if ($.os.search(/windows/i) != -1) {fileLineFeed = "Windows" }
else { fileLineFeed = "Macintosh"}
// create the output file accordingly
fileOut = new File("~/Desktop/Histogram.log")
fileOut.lineFeed = fileLineFeed
fileOut.open("w", "TEXT", "????")
// write out a header
fileOut.write("Histogram report for " + docRef.name)
// find out how many pixels I have
var totalCount = docRef.width.value * docRef.height.value
// more info to the out file
fileOut.write(" with a total pixel count of " + totalCount + "\n")
// channel indexer
var channelIndex = 0
// remember which channels are currently active
var myActiveChannels = app.activeDocument.activeChannels
// document histogram only works in these modes
if (docRef.mode == DocumentMode.RGB ||docRef.mode == DocumentMode.INDEXEDCOLOR ||docRef.mode == DocumentMode.CMYK) {
    // activate the main channels so we can get the documents histogram
    TurnOnDocumentHistogramChannels(docRef)
    // Output the documents histogram
    OutputHistogram(docRef.histogram, "Luminosity", fileOut)
// local reference to work from
var myChannels = docRef.channels
// loop through each channel and output the histogram
for (var channelIndex = 0; channelIndex < myChannels.length; channelIndex++) {
    // the channel has to be visible to get a histogram
    myChannels[channelIndex].visible= true
    // turn off all the other channels
    for (var secondaryIndex = 0; secondaryIndex < myChannels.length;secondaryIndex++) {
        if (channelIndex != secondaryIndex) { myChannels[secondaryIndex].visible= false }
    // Use the function to dump the histogram
    OutputHistogram(myChannels[channelIndex].histogram,myChannels[channelIndex].name, fileOut)
// close down the output file
fileOut.close()
alert("Histogram file saved to: " + fileOut.fsName)
// reset the active channels
docRef.activeChannels = myActiveChannels
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits
app.preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs
// Utility function that takes a histogram and name
// and dumps to the output file
function OutputHistogram(inHistogram, inHistogramName, inOutFile) {
    // find ouch which count has the largest number
    // I scale everything to this number for the output
    var largestCount = 0
    // a simple indexer I can reuse
    var histogramIndex = 0
    // see how many samples we have total
    var histogramCount = 0
    // search through all and find the largest single item
    for (histogramIndex = 0; histogramIndex < inHistogram.length;histogramIndex++) {
        histogramCount += inHistogram[histogramIndex]
        if (inHistogram[histogramIndex] > largestCount)
        largestCount = inHistogram[histogramIndex]
    // These should match
    if (histogramCount != totalCount) {
        alert("Something bad is happening!")
    // see how much each "X" is going to count as
    var pixelsPerX = largestCount / 100
    // output this data to the file
    inOutFile.write("One X = " + pixelsPerX + " pixels.\n")
    // output the name of this histogram
    inOutFile.write(inHistogramName + "\n")
    // loop through all the items and output in the following format
    // 001
    // 002
    for (histogramIndex = 0; histogramIndex < inHistogram.length;histogramIndex++) {
    // I need an extra "0" for this line item to keep everything in line
    if (histogramIndex < 10)
        inOutFile.write("0")
    // I need an extra "0" for this line item to keep everything in line
    if (histogramIndex < 100)
        inOutFile.write("0")
    // output the index to file
    inOutFile.write(histogramIndex)
    // some spacing to make it look nice
    inOutFile.write(" ")
    // figure out how many X’s I need
    var outputX = inHistogram[histogramIndex] / largestCount * 100
    // output the X’s
    for (var a = 0; a < outputX; a++)
        inOutFile.write("X")
    inOutFile.write("\n")
inOutFile.write("\n")

Similar Messages

Maybe you are looking for

  • GR Document

    Hello Experts, I have a FI document ( Dr GR/IR Account, Cr Vendor Account) and i need to find out the Vendor Invoice Number ( or MM document) from this one. How do i find out? I am guessing that if i find the GR document ( Dr Inventory, Cr GR/IR docu

  • Lenovo g550 cursor moving Please help

    Im struggling on here really....lol.... Im having trouble with my G550.......when im typing ....if im not watching the screen when typing, I find the cursor has moved into the middle of another word after pressing the space bar......also, after press

  • Weblogic 7 can support jsf?  i come from china

    I was small to try once, seeming not to go. If I want to use weblogic not 7 do jsf how to do, isn't a ducting what jar wrap all right Have the solution none

  • Migration Assistant not working with OS X Lion via Wireless Network?

    Anybody know how to assist me here? Basically, I have two iMacs on seperate floors of my home.  They are newer models (both purchased last year) and I have upgraded both of them to Lion and just ran a system update on both of them to ensure they are

  • Will there be a patch beta?

    I, like many, have experienced the iTunes 5 services related problem. Is sounds as if Apple is working to correct this problem with a patch My question is - Does Apple run a (closed or open) Beta for their patches and product revs? I have found runni