Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Resizer

1523745289

Edited 1523997839
Robin
API Scripter
Someone in a Discord server I am part of asked me if it was possible to make a resize script for maps, so I did some testing and came up with this script. <a href="https://github.com/RobinKuiper/Roll20APIScripts/tr" rel="nofollow">https://github.com/RobinKuiper/Roll20APIScripts/tr</a>... Thanks to&nbsp; Bast L. I have also added scaling of the entire page now. Commands !resizer [width] [height] - Resizes the selected graphic(s). !resizer page [width] [height] [?pixels] - Resizes the page (add pixels add the end to resize in pixels instead of units). !resizer - Shows the Resizer menu (if there are graphics selected it also shows there current sizes). !resizer page - Shows the pages current size. !resizer scale [amount] [up/down] - Scales the page (and all objects on it) to the amount given. !resizer fit [?keep_ratio] - Fits the selected graphics to fit the page (handy for maps), add `keep_ratio` to the end to keep the aspect ratio of the selected graphic. !resizer center [?horizontal] [?vertical] - Center the selected graphic(s), add `h`, `hor` or `horizontal` for horizontal and `v`, `ver` or `vertical` for vertical centering. !resizer help - Shows the help menu. !resizer config - Shows the config menu. !resizer menu - Shows a menu to easily resize graphics/pages.
1523750914
Robin
API Scripter
I have changed the commands.
1523769140
GiGs
Pro
Sheet Author
API Scripter
You can do this with TokenMod too, but more options are always better.
1523783841
Robin
API Scripter
G G said: You can do this with TokenMod too, but more options are always better. I did not know this. I just saw it indeed. But it can't change the size of the whole page, I believe?
1523787883
Robin
API Scripter
Thanks to Bast L. I have also added scaling of the entire page now.
1523792856
GiGs
Pro
Sheet Author
API Scripter
Robin K. said: G G said: You can do this with TokenMod too, but more options are always better. I did not know this. I just saw it indeed. But it can't change the size of the whole page, I believe? If you mean the page settings, then no it cant. That's handy! TokenMod can change the size of a map that covers the page, but it's only for changing objects (graphics, tokens, etc.) on the page not the page itself.
1523814365
Robin
API Scripter
I have also added a 'fit' command now, !resizer fit This will make the selected graphic(s) fit the page size, real handy for maps.
1523814532
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's pretty durn useful!
1523816191
GiGs
Pro
Sheet Author
API Scripter
How does fit &nbsp;handle maps whose aspect ratio is different to the page's aspect ratio?
1523820131
Robin
API Scripter
I have added an option to keep the aspect ratio.
Nice, tried it out on tomb of horrors and against the giants. Worked great.
1523997872
Robin
API Scripter
I have added a feature to center selected graphic(s) on the page horizontally and/or vertically.
1523998735

Edited 1524005181
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Wow, with that change, this would work very well with my&nbsp; Scenes macro for Theatre of the Mind . I'll have to do some testing and rewrite. Note, since it requires an API script to run, the post is on the Pro forum.
1523999181
Robin
API Scripter
keithcurtis said: Wow, with that change, this would work very well with my&nbsp; Scenes macro for Theatre of the Mind . I'll have to do some testing and rewrite. Your url isn't working :(
Your url isn't working :( Worked for me. Internet has been blotchy lately. try again.
1524000065
Robin
API Scripter
For some reason it takes me to the "My Games" page.
1524000149
The Aaron
Pro
API Scripter
It's on the Pro forum, that's why you can't see it.
1524000187
The Aaron
Pro
API Scripter
I can move it to Specific Use, if KeithCurtis wants me to. =D
1524003029
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It should stay where it is, since it requires an API script (Pro Feature) to run, but is not an API script in and of itself. I assumed that since this thread is on the API forum, it would only be visible to Pro users. I'll edit the post to make note of this.
1524003190
The Aaron
Pro
API Scripter
API forum is publicly visible (because players often use scripts but aren't Pro).
1524005317
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That makes perfect sense. Since this is a GM only usage, it should stay put. However, if it can convince anyone of the marvels available to Pro level subscription, here is a link to the&nbsp; video of the macro and script in action.
1524975049
GiGs
Pro
Sheet Author
API Scripter
I've just been playing around with this and notice the script doesnt seem to respond to !resizer. I had to disable the script, and re-enable it, to get the config menu to appear, and could get it to work by clicking the buttons. I noticed that the commands in chat were all starting with !help not !resizer Looking at the script itself, I notice that there's no check for the command name resizer that I can spot. The handle chat input section looks like this: handleInput = (msg) =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; if (msg.type != 'api' || !playerIsGM(msg.playerid)) return; &nbsp; &nbsp; &nbsp; &nbsp; // Split the message into command and argument(s) &nbsp; &nbsp; &nbsp; &nbsp; let args = msg.content.split(' '); &nbsp; &nbsp; &nbsp; &nbsp; let command = args.shift().substring(1); &nbsp; &nbsp; &nbsp; &nbsp; let extracommand = args.shift(); Notice how there's nothing similar to&nbsp; if(msg,content.indexOf("!resizer") &gt; -1) The script just seems to assume its there, and then removes the first word at the start of the command.
1524995369
Robin
API Scripter
G G said: I've just been playing around with this and notice the script doesnt seem to respond to !resizer. I had to disable the script, and re-enable it, to get the config menu to appear, and could get it to work by clicking the buttons. I noticed that the commands in chat were all starting with !help not !resizer Looking at the script itself, I notice that there's no check for the command name resizer that I can spot. The handle chat input section looks like this: handleInput = (msg) =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; if (msg.type != 'api' || !playerIsGM(msg.playerid)) return; &nbsp; &nbsp; &nbsp; &nbsp; // Split the message into command and argument(s) &nbsp; &nbsp; &nbsp; &nbsp; let args = msg.content.split(' '); &nbsp; &nbsp; &nbsp; &nbsp; let command = args.shift().substring(1); &nbsp; &nbsp; &nbsp; &nbsp; let extracommand = args.shift(); Notice how there's nothing similar to&nbsp; if(msg,content.indexOf("!resizer") &gt; -1) The script just seems to assume its there, and then removes the first word at the start of the command. In the config is an option to change the command of the script: I do this in all of my scripts, to avoid conflict with other scripts, and people can just set the command they want for themselfes. Probably something went wrong there. If you restart the API Sandbox and check the API Log you find this line: That is the command the script is currently using. You can than type that command in chat followed by config, eg.: !resizer config And reset the config back to default (or just change the command).
1525021005
GiGs
Pro
Sheet Author
API Scripter
Ah that explains it. Thanks!
1525021078
Robin
API Scripter
No problem! Have fun with it!