Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:20:20+00:00 2026-06-05T18:20:20+00:00

I am intermediate with Javascript, but am not so familiar with Adobe’s Extendscript. For

  • 0

I am intermediate with Javascript, but am not so familiar with Adobe’s “Extendscript”. For practice and a better understanding of InDesign’s code structure, I am trying to access properties of an image via rectangles.images.

Is this possible to access say, the file name of an image, through rectangles.images? Also I am interested if it’s possible to access the image’s color attributes this way, say to convert it to greyscale?

Here is my approach so far:

for(var i = 0; i < app.activeDocument.rectangles.length; i++)
{
    var imageType = app.activeDocument.rectangles[i].images.constructor.name;

    switch(imageType)
    {
        case "Images":
            alert(app.activeDocument.rectangles[i].images.name); // "name" is not a valid property here!
            break;

        default:
            alert("There are no images in this file.");
    }
}

Also, is it possible to determine the file-type of the image with .rectangles.images.constructor.name? I would like to add an extra case for say, PDF’s or jpegs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:20:21+00:00Added an answer on June 5, 2026 at 6:20 pm

    You shouldnt use the constructor unless you want to try and determine what type of JS Object it is which you dont need to do in this case because the images collection is only going to contain images. The file property will actually be on an image’s related Link object.

    Note none of this is tested i jsut took my knowledge of JS and the API documentation and reworked your code…

    var rect = app.activeDocument.rectangles,
        imgs,
        filePath,
        hasImages = false;
    
    for(var i = 0; i < rect.length; i++) {
        imgs = rect[i].images;
        if( imgs.length > 0) {
    
          hasImages = true;
          for (var j = 0; j < imgs.length; j++) {
             filePath = imgs[j].itemLink ? imgs[j].itemLink.filePath : null; 
             switch (imgs[j].imageTypeName) {
                 case 'jpeg':
                    alert('This is a JPEG:' + filePath);
                    break;
                 case 'pdf':
                    alert('This is a PDF: '+filePath);
                    break;
                 default:
                   alert('Default case - '+imgs[j].imageTypeName+': '+filePath);
             }
          }
       }
    } 
    
    if(!hasImages) {
       alert('No images in document');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to achieve the following though with my intermediate JavaScript skills I'm not
I'm a novice-to-intermediate JavaScript/jQuery programmer, so concrete/executable examples would be very much appreciated. My
I'm writing a compiler which uses C as an intermediate code which is (Currently)
I'm reasonably comfortable with javascript and php; I'd say I'm an intermediate. I'm starting
I am an intermediate javaScript programmer, and i am interested in expanding my knowledge
This is a general question about backbone.js and javascript, I'm intermediate in javascript: If
Javascript has global and local variables. How can I have intermediate scope at html
I have intermediate knowledge of flash and actionscript, but I have never done 3D
I'm an intermediate PHP programmer, but am struggling with the output of the Google
I am taking an intermediate programming course which stresses the use of invariants. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.