Skip to content

How to get image bounds without taking into account empty space? #2357

Closed Answered by Zhiul
Zhiul asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for your answer! I didn't formulate the question well, what I actually meant was to get the bounds of the image including x and y relative to the whole viewport. I also needed the value in px, I achieved it in this way:

function getImagePositionOnViewerElement() {
    const viewportBounds = viewer.viewport.getBounds();
    const imageSize = viewer.world.getItemAt(0).getSizeInWindowCoordinates();

    return {
        x: Math.abs(viewportBounds.x) * imageSize.x,
        y: Math.abs(viewportBounds.y) * imageSize.x
    }
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Zhiul
Comment options

Answer selected by Zhiul
@iangilman
Comment options

@Zhiul
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants