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

Problem with scripting geometricbounds on a .tif image

New Here ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

Hello friends. 

 

I have a problem with setting geometricbounds of an image in javascript. I submit x, y, width, height and scale X and scale Y percentage. All my params are applied except the X and the Y. I applied these params this way : 

for(var j=0;j<page_item.allPageItems.length;j++)
                    {
                        var sub_page_item = page_item.allPageItems[i];
                        if(sub_page_item instanceof Image)
                        {       
                            var itm = sub_page_item;
                            var gb = [x, y, width, height];
                            itm.geometricBounds = gb;
                            itm.horizontalScale = zoomX;
                            itm.verticalScale = zoomY;
                            
                        }
                    }

 

Did someone has this kind of problem in the past ? Does someone have a solution ? Thanks for your help. 

TOPICS
Bug , Print , Scripting

Views

148

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

correct answers 1 Correct answer

Community Expert , Oct 21, 2021 Oct 21, 2021

The parameters for geometricBounds are not:

[ x, y, width, height ]

 

They are:

 

y for upper left corner ,

x for upper left corner ,

y for lower right corner,

x for lower right corner

 

Regards,
Uwe Laubender

( ACP )

Votes

Translate

Translate
Community Expert ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

The parameters for geometricBounds are not:

[ x, y, width, height ]

 

They are:

 

y for upper left corner ,

x for upper left corner ,

y for lower right corner,

x for lower right corner

 

Regards,
Uwe Laubender

( ACP )

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 ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

thanks. I 'm gonna try that. We didn't understand the geometric bounds logical. So, if we set the 4 corners, we don't need to set height and with?

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
Community Expert ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

LATEST

You could set the width and height to variables and use them in the bounds. Some thing like this sets the selection to 3 x 2 ruler units:

 

 

var s = app.documents[0].selection[0];

var y = 1
var x = 1
var h = 2
var w = 3

s.geometricBounds = [y, x, y+h, x+w] 


alert("Width: " + getWidthHeight(s)[0] + "   Height: " + getWidthHeight(s)[1])

/**
* Get a page item’s width and height 
*  the page item 
*  an array [width, height] 
* 
*/
function getWidthHeight(pi){
    var wh = []
    var gb = pi.geometricBounds
    wh[0] = gb[3]-gb[1];
    wh[1] = gb[2]-gb[0]
    return wh
}

 

 

 

Screen Shot 22.png

 

 

 

Screen Shot 24.png

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
Community Expert ,
Oct 21, 2021 Oct 21, 2021

Copy link to clipboard

Copied

You have two points that are described by two pairs of y and x values.

Geometric bounds always form a rectangular area where the edges of the rectangle are always parallel to the rulers in a layout window. That's all.

 

Regards,
Uwe Laubender

( ACP )

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