Highlighted

Script to remove whitespace

Explorer ,
Jul 05, 2020

Copy link to clipboard

Copied

So I am attempting to effectively crop a logo, removing any unused space to the right of the last object and below...

I'm having the WORST time doing it.

I've come with the idea of..
-Merging all layers into one
-get demensions of that remaing layer
-resizeing page to those demensions.


Having issues merging all into one.  I guess "app.activedocument.mergevisiblelayers" use to be a function but is not anymore? Because I can't get it to work..

Any thoughts about how to do this easier or even just merging layers would be great!!
Thanks in advance!

Sorry, I got sidetracked with so much other stuff I forgot to reply.

 

But this did not work... It kicked off an error. I forget what one, I can go back and see if anyone is curious.

 

What I ended up doing was

-Converting text to outlines
-Selecting all images
-Getting bounds

-resizing based on the globalBounds[2]

 

Looked something like this

        currentPage.textFrames.everyItem().createOutlines();

        //Select items on current page
        for (var j=0; j<currentPage.pageItems.length; j++)
        {
            currentPage.pageItems.everyItem().select();
        }

        //Get outer bounds of selection for resize
        var gb = app.activeDocument.selection[0].geometricBounds;

        //Resize vertical banners
        currentPage.resize(CoordinateSpaces.INNER_COORDINATES,
            AnchorPoint.TOP_LEFT_ANCHOR,
            ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
            [2000, gb[2]] );

 But huge thanks for all the help!

 

Topics

How to, Scripting

Views

205

Likes

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

Script to remove whitespace

Explorer ,
Jul 05, 2020

Copy link to clipboard

Copied

So I am attempting to effectively crop a logo, removing any unused space to the right of the last object and below...

I'm having the WORST time doing it.

I've come with the idea of..
-Merging all layers into one
-get demensions of that remaing layer
-resizeing page to those demensions.


Having issues merging all into one.  I guess "app.activedocument.mergevisiblelayers" use to be a function but is not anymore? Because I can't get it to work..

Any thoughts about how to do this easier or even just merging layers would be great!!
Thanks in advance!

Sorry, I got sidetracked with so much other stuff I forgot to reply.

 

But this did not work... It kicked off an error. I forget what one, I can go back and see if anyone is curious.

 

What I ended up doing was

-Converting text to outlines
-Selecting all images
-Getting bounds

-resizing based on the globalBounds[2]

 

Looked something like this

        currentPage.textFrames.everyItem().createOutlines();

        //Select items on current page
        for (var j=0; j<currentPage.pageItems.length; j++)
        {
            currentPage.pageItems.everyItem().select();
        }

        //Get outer bounds of selection for resize
        var gb = app.activeDocument.selection[0].geometricBounds;

        //Resize vertical banners
        currentPage.resize(CoordinateSpaces.INNER_COORDINATES,
            AnchorPoint.TOP_LEFT_ANCHOR,
            ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
            [2000, gb[2]] );

 But huge thanks for all the help!

 

Topics

How to, Scripting

Views

206

Likes

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
Adobe Community Professional ,
Jul 06, 2020

Copy link to clipboard

Copied

This is the InDesign scripting forum, you probably want the Photoshop scripting forum.

Likes

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
Reply
Loading...
Explorer ,
Jul 06, 2020

Copy link to clipboard

Copied

No, I am trying to do this in InDesign

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 06, 2020

Copy link to clipboard

Copied

The only way to crop a graphic in InDesign is to resize the image's container. But unlike in Photoshop, you can't check the state of pixels. In InDesign, cropping is a visual/manual thing.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 06, 2020

Copy link to clipboard

Copied

I guess "app.activedocument.mergevisiblelayers" use to be a function but is not anymore?

 

That is a Photoshop function:

 

https://theiviaxx.github.io/photoshop-docs/Photoshop/Document.html

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 06, 2020

Copy link to clipboard

Copied

Are the pixels you are trying to crop transparent? If that’s the case you might be able to add a clipping path based on transparency, followed by a fit frame to content, and then a removal of the clipping path. When I do that witht the ID UI it works (top version):

 

Screen Shot.png

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ClippingPathSettings.html

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Fitting.html

 

Likes

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
Reply
Loading...
Explorer ,
Jul 06, 2020

Copy link to clipboard

Copied

This looks like exactly what I need...  If its not a hassle, help!? LOL
ClippingPathSettings get applies to what method exactly?

 

 

    ClippingPathSettings.clippingType = ClippingPathType.DETECT_EDGES;

//  I assume I need something here.
    Fitting.FIT_FRAME_TO_CONTENT;​

 

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 07, 2020

Copy link to clipboard

Copied

Something like this where the selection is the logo:

 

var img=app.activeDocument.selection[0]
img.clippingPath.clippingType = ClippingPathType.DETECT_EDGES;
img.fit(FitOptions.FRAME_TO_CONTENT);
img.clippingPath.clippingType = ClippingPathType.NONE;

Likes

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
Reply
Loading...
Explorer ,
Jul 08, 2020

Copy link to clipboard

Copied

So I'm being told the image is an "undefined object" and the script fails..

Likes

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
Reply
Loading...
Explorer ,
Jul 08, 2020

Copy link to clipboard

Copied

I think the issue is it's a few items..?  

Likes

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
Reply
Loading...
Explorer ,
Jul 08, 2020

Copy link to clipboard

Copied

Just to make myself clear, because I'm sure I'm not... Honestly, I don't know indesign so I may be using the word verbage but

I have a page.             A layer with a logo             A layer of text                And a second layer of text

-------------                  -------------                             -------------                  -------------

|                |                 |      S$$    |                             |                |                  |                |    

|                |                 |                |                             |     Text    |                  |      text     |      

|                |                 |                |                             |                |                  |       text    |      

-------------                 -------------                             -------------                   -------------   

 

Assuming I am only using the logo and the first layer of text, I am trying to trim the extra page sitting below so that when I export as a png or jpg that extra white space is gone.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 08, 2020

Copy link to clipboard

Copied

As Uwe suggests, use the Direct Selection tool (white arrow) and click an image to select before running the script.

 

This is the image selected:

 

Screen Shot 4.png

 

And this is its parent frame selected:

 

Screen Shot 5.png

 

Selecting the image and running the script collapses the parent frame to the image edge. The collapsed parent frame selected:

 

Screen Shot 6.png

 

 

 

Likes

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
Reply
Loading...
Explorer ,
Jul 20, 2020

Copy link to clipboard

Copied

Sorry, I got sidetracked with so much other stuff I forgot to reply.

 

But this did not work... It kicked off an error. I forget what one, I can go back and see if anyone is curious.

 

What I ended up doing was

-Converting text to outlines
-Selecting all images
-Getting bounds

-resizing based on the globalBounds[2]

 

Looked something like this

        currentPage.textFrames.everyItem().createOutlines();

        //Select items on current page
        for (var j=0; j<currentPage.pageItems.length; j++)
        {
            currentPage.pageItems.everyItem().select();
        }

        //Get outer bounds of selection for resize
        var gb = app.activeDocument.selection[0].geometricBounds;

        //Resize vertical banners
        currentPage.resize(CoordinateSpaces.INNER_COORDINATES,
            AnchorPoint.TOP_LEFT_ANCHOR,
            ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
            [2000, gb[2]] );

 But huge thanks for all the help!

 

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 06, 2020

Copy link to clipboard

Copied

Hi Rob,

depending on the contents of the image this would work more or less good.

 

The precise way would be to open the image with PhotoShop, do one or more selections there and use the bounds of the selections to get an idea and precise numbers for a cropping action in InDesign. This would require a BridgeTalk object in the script to address all parts done with PhotoShop.

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 08, 2020

Copy link to clipboard

Copied

Hi HoochShepherd,

to run Rob's script successfully you have to select the placed image itself.

Not the container frame that holds the image.

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Reply
Loading...