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

Need help finding my Inner Glow!

New Here ,
Aug 19, 2011 Aug 19, 2011

Copy link to clipboard

Copied

Hello,

I am atempting to write a script in JS that will look at each image on a page and identify if Effects>Inner Glow has been applied to the image.  Below is what I have so far but the script is returning "false" on every image even when some images do have inner glow.  I was up too late last night trying to get this to work so I figured it's time to ask for help.

var myDocument = app.activeDocument;

var myGraphicArray = myDocument.pages.allGraphics;  //pages is an array of all pages in pub

var myGraphicNumber = myGraphicArray.length;

for(i=0; i<myGraphicNumber; i++)

{

     if(myGraphicArray instanceof Image)

     {

          var myInnerGlowSetting = myGraphicArray.transparencySettings.innerGlowSettings.applied;  //I know this is where the issue is!!!

          alert(myInnerGlowSetting);  //returns false on every image even if they do have inner glow

          if(myInnerGlowSetting == true)

          {

               alert ("INNER GLOW ON IMAGE");

          }

     }

}

THANKS for any and all help!

Have a great day

Brant

TOPICS
Scripting

Views

983

Translate

Translate

Report

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
Guide ,
Aug 19, 2011 Aug 19, 2011

Copy link to clipboard

Copied

Thank you. The title of this thread made me smile.

Sorry I can't help you.

Votes

Translate

Translate

Report

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
Enthusiast ,
Aug 19, 2011 Aug 19, 2011

Copy link to clipboard

Copied

I think you're iterating over allGraphics when you should be using pageItems or allPageItems. allPageItems in CS5 will give you an array of all the page Items and their image contents, which may be what you want—though usually I think those kinds of transparency effects are applied to the frames rather than their contents. pageItems will give you a collection of page items but not their contents, but won't give you access to any grouped items without descending through each group recursively.

I'm not sure what your document looks like or what your end goal is, so I'm not sure which to recommend. In either case you will want to remove your "myGraphicArray instanceof Image" check, since that will limit your alerts (or whatever you're going to be doing with this information) to certain kinds of frame contents and will leave out the frames themselves, where the transparency effects are most likely applied.

Jeff

Votes

Translate

Translate

Report

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 ,
Aug 19, 2011 Aug 19, 2011

Copy link to clipboard

Copied

Funny thing is this worked just fine for me… If Im understanding it's intent correctly? Are you sure you applied the effect to the image or its containing frame?

Votes

Translate

Translate

Report

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 ,
Aug 19, 2011 Aug 19, 2011

Copy link to clipboard

Copied

Thanks for the feedback!  I think I've managed to accomplish what I was after.  Long story short - I am attempting to create a script that exports a PDF for each page of a publication.  It the script finds an image with a specific effect (inner shadow, inner glow, satin..) it uses PDF export preset A, if not then use PDF export preset B.  We are having trouble with some image/frame effects causing our OPI software (Odystar) to not pick up the image data.  If anyone has any comments on why that might be feel free to chime in!!

@Muppet Mark - You were right. I had the inner glow applied to the frame.  Once I applied it to the image the script caught it.

Thanks again,

Brant

Votes

Translate

Translate

Report

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 ,
Aug 21, 2011 Aug 21, 2011

Copy link to clipboard

Copied

Here is a function I use to check if an effect is applied to a page item:

function IsEffectApplied(pageItem) {
     var currentSettings;     
     var result = false;
     var allTransparencySettings = [];
     allTransparencySettings.push(pageItem.transparencySettings);
     allTransparencySettings.push(pageItem.fillTransparencySettings);
     allTransparencySettings.push(pageItem.strokeTransparencySettings);
     allTransparencySettings.push(pageItem.contentTransparencySettings);
     
     for (var i = 0; i < allTransparencySettings.length; i++) {
          currentSettings = allTransparencySettings;
          with (currentSettings) {
               if (innerShadowSettings.applied) result = true;
               if (outerGlowSettings.applied) result = true;
               if (innerGlowSettings.applied) result = true;
               if (bevelAndEmbossSettings.applied) result = true;
               if (satinSettings.applied) result = true;
               if (gradientFeatherSettings.applied) result = true;
               if (directionalFeatherSettings.applied) result = true;
               if (dropShadowSettings.mode == ShadowMode.DROP) result = true;
               if (featherSettings.mode == FeatherMode.STANDARD) result = true;
          }
     }     
     return result;
}

Kasyan

Votes

Translate

Translate

Report

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 ,
Aug 22, 2011 Aug 22, 2011

Copy link to clipboard

Copied

Kasyan, it's early morning and I've only had the 1 coffee so far… but won't 'result' just be the last 'if' result… I would have expected to see…

function IsEffectApplied(pageItem) {      var currentSettings;      var allTransparencySettings = [];      allTransparencySettings.push(pageItem.transparencySettings);      allTransparencySettings.push(pageItem.fillTransparencySettings);      allTransparencySettings.push(pageItem.strokeTransparencySettings);      allTransparencySettings.push(pageItem.contentTransparencySettings);           for (var i = 0; i < allTransparencySettings.length; i++) {           currentSettings = allTransparencySettings;           with (currentSettings) {                if (innerShadowSettings.applied) return true;                if (outerGlowSettings.applied) return true;                if (innerGlowSettings.applied) return true;                if (bevelAndEmbossSettings.applied) return true;                if (satinSettings.applied) return true;                if (gradientFeatherSettings.applied) return true;                if (directionalFeatherSettings.applied) return true;                if (dropShadowSettings.mode == ShadowMode.DROP) return true;                if (featherSettings.mode == FeatherMode.STANDARD) return true;           }      }          return false; }

Votes

Translate

Translate

Report

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
LEGEND ,
Aug 22, 2011 Aug 22, 2011

Copy link to clipboard

Copied

Muppet Mark wrote:

Kasyan, it's early morning and I've only had the 1 coffee so far… but won't 'result' just be the last 'if' result… I would have expected to see…

Maybe you should try chocolate instead?

If an if is false, then result is left unchanged. So Kasyan's version should work fine.

Your version will be slightly faster, since it returns as soon as it finds an effect applied. But some people would say it is bad style to return from the middle of the function, because it makes it harder to see the control flow when you glance at the program. Of course it can be done with break;.

Votes

Translate

Translate

Report

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 ,
Aug 22, 2011 Aug 22, 2011

Copy link to clipboard

Copied

No chocolate to sleep… Until I've had enough coffee to keep me awake… Yup I looked again and you are quite right John… That's why the 'muppet' is there… Exiting a function ASAP is just how I would have done this (good or bad)… Would have probably ordered the if's for most common at top too but thats just me…

Votes

Translate

Translate

Report

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 ,
Aug 22, 2011 Aug 22, 2011

Copy link to clipboard

Copied

There are always a few ways to achieve the same task, Mark.

Votes

Translate

Translate

Report

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 ,
Aug 22, 2011 Aug 22, 2011

Copy link to clipboard

Copied

LATEST

Kasyan, I noticed my mistake not long after posting… John is too fast and I can't retract my post now… I just skinned the same cat… with a different knife…

Votes

Translate

Translate

Report

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