Skip navigation
zjtonywang
Currently Being Moderated

get image bound(x,y coordinate) on layer

Mar 22, 2012 7:03 AM

HI!

    I am new at automation plug develop and I want get the Image bound(position) on layer . I try  code like:  PIUGetInfo(classOffset,keyHorizontal,...) but it is not work at all. I try the vbs code like : docRef.ArtLayers(1).Bounds  it can work. is there  function or routine in photoshop SDK can get image bound? thanks!

 
Replies
  • Currently Being Moderated
    Jun 5, 2012 1:34 AM   in reply to zjtonywang

    Have you tried something like this:

     

                DescriptorTypeID runtimeKeyID;

                DescriptorTypeID runtimeClassID;

                DescriptorClassID descClass;

     

                PIActionDescriptor descLayer = NULL;

                PIActionDescriptor descPosition = NULL;

     

                double top= 0;

                double left= 0;

                double bottom= 0;

                double right= 0;

     

                int LayerCounter;

     

                ...

     

     

                error = PIUGetInfoByIndex(LayerCounter,classLayer,0,&descLayer,NULL);

                if (error) goto returnAutoError;

     

                error = sPSActionControl->StringIDToTypeID("bounds", &runtimeKeyID);

                if (error) goto returnAutoError;

     

                error = sPSActionControl->StringIDToTypeID("classRectangle", &runtimeClassID);

                if (error) goto returnAutoError;

     

                error = PIUGetSingleItemFromDescriptor(descLayer,runtimeKeyID,&descPosition,& descClass);

                if (error) goto returnAutoError;

     

                error = sPSActionDescriptor->GetFloat(descPosition, keyTop, &top);

                if (error) goto returnAutoError;

                error = sPSActionDescriptor->GetFloat(descPosition, keyLeft, &left);

                if (error) goto returnAutoError;

                error = sPSActionDescriptor->GetFloat(descPosition, keyBottom, &bottom);

                if (error) goto returnAutoError;

                error = sPSActionDescriptor->GetFloat(descPosition, keyRight, &right);

                if (error) goto returnAutoError;

     

                ...

     

                returnAutoError:

                if (descLayer != NULL) sPSActionDescriptor->Free(descLayer);

                if (descPosition != NULL) sPSActionDescriptor->Free(descPosition);

                ...

                  

    Try running Getter when you have opened file in Photoshop, it will give you every information that can be get from layer. Actualy Getter makes the code as it is making or "Putting" info to Photoshop but rewritting the code is simple.

     

    Hope this helps,

    Momir Zecevic

    Ars Media

    www.arsmedia.tv

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points