# Getting canvas size vs pixel size

**URL:** <https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162>\
**Category:** UXP Plugin API\
**Tags:** uxp, javascript\
**Created:** [April 8, 2023, 6:08am UTC](https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162 "2023-04-08T06:08:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpheneger](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jpheneger](https://forums.creativeclouddeveloper.com/u/jpheneger)\
**Post date:** [April 8, 2023, 6:08am UTC](https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162/1 "2023-04-08T06:08:37Z")

</div>

I am attempting to get the bounds of smart object layers where the layer is 100x100 pixels, but ehen I get the layer bounds it only returns the sixe of the area within the canvas that has pixel data (62x62). Is it possible to get the canvas size from each layer rather than the bounds whic seems to return only thepixel data size?

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [April 8, 2023, 10:16am UTC](https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162/2 "2023-04-08T10:16:45Z")

</div>

you can use batchPlay and play “get” action… it should be “smartObjectMore” property of the “layer” …somewhere in that object.

---

<div class="post-metadata">

**Author:** ![jpheneger](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jpheneger](https://forums.creativeclouddeveloper.com/u/jpheneger)\
**Post date:** [April 30, 2023, 4:20pm UTC](https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162/3 "2023-04-30T16:20:47Z")

</div>

Every time I attempt to write a batchPlay for this I get the error:

> The command “\< unknown \>” is not currently available.

Would you possibly be able to provide me with a snippet that uses the “get” action to access the “smartObjectMore” property?

Here is my snippet:

```auto
let command = [{ _obj: 'get' }];
const result = await action.batchPlay(
	command,
	{ synchronousExecution: true }
)[0];
console.log(`Result: ${JSON.stringify(result)}`);

```

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [April 30, 2023, 4:36pm UTC](https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162/4 "2023-04-30T16:36:14Z")

</div>

```auto
const {batchPlay} = require("photoshop").action;

const result = await batchPlay(
   [
      {
         _obj: "get",
         _target: [
            {
               _property: "smartObjectMore"
            },
            {
               _ref: "layer",
               _id: 1231
            },
            {
               _ref: "document",
               _id: 137
            }
         ],
         _options: {
            dialogOptions: "dontDisplay"
         }
      }
   ],
   {}
);

const pinned = result[0].smartObjectMore.size;

```

Alchemist plugin can generate code snippets for you

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/6/66a167502e408126551a084bf118ea687a21b124.png)

[http://alchemist.cool/](http://alchemist.cool/)

---

<div class="post-metadata">

**Author:** ![jpheneger](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jpheneger](https://forums.creativeclouddeveloper.com/u/jpheneger)\
**Post date:** [April 30, 2023, 5:19pm UTC](https://forums.creativeclouddeveloper.com/t/getting-canvas-size-vs-pixel-size/6162/5 "2023-04-30T17:19:53Z")

</div>

Thank you! This is exactly what I needed!
