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

Video Tutorial - Resizing Maps & Pages

1583454765
Nick O.
Forum Champion
I created another video tutorial . This one shows how to automatically resize a page and a map to specified dimensions, center the map, and put it on the map layer. Feedback is always welcome! :)
1583460433
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I'm going to repeat my Youtube comment here, since the forum might be easier to discuss on: Another winner! I appreciate the time and effort you put into explaining error checking. One question: Most users are likely to size a map by the number of units (by counting squares), especially since a given map may not have been produced at 70px/unit. Is there a reason you chose to use pixels for the command?
1583496392
Nick O.
Forum Champion
I'll repost my reply here, too. :)  Thanks, Keith! I picked pixels because that's what the graphic object uses for its width & height properties. It didn't occur to me that people might size in units other than that (when I grab images for my backgrounds I just right-click on them in Windows, look at the dimensions of the image in Properties and then size according to that). I'd be happy to do a follow up video showing how to tweak the script to use units instead, but in looking at the documentation for the Page object in the API, it doesn't look like there's a way to see how many pixels make up a single unit. Because of that, I'm not sure how to convert the number of units into pixels like the graphics object needs. Open to suggestions/thoughts, though. :)
1583512607
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The 70 px/unit page setting seems fixed. If your map is 20 squares by 20 squares, size it to 1400x1400px and the page to 20x20u. It's basically the conversion you did in your script, but in reverse. Roll20 is constantly serving the graphics at the current magnification size, so there's no need to worry about what the native resolution of the graphic is. Count the squares on the map, put those into the API command. The script multiplies by 70 to set the image to size at 70ppu, and sets the page with the unconverted number.
1583517252
Nick O.
Forum Champion
Cool, thanks. I'll work on creating a part 2 that lets folks specify if they want to use pixels or units when resizing.
1583535816
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That might be a good excuse to introduce adding options to an API: !mapSizer --units 20 20 !mapSizer --pixels 1400 1400
1583542688

Edited 1583542730
Nick O.
Forum Champion
On it! :) I've already updated the code, I'll try to record the vid sometime this weekend. Question, though - I've noticed a bunch of folks include the -- in their parameters. Is that a standard from somewhere?
1583546683
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I think it's just convention, but the Aaron would probably be the person to ask. It's certainly not universal.
1583593576
Nick O.
Forum Champion
Just posted part 2 of the vid, which covers how further enhance the script so it lets the user specify units or pixels&nbsp; <a href="https://youtu.be/k0yfiVhwG2w" rel="nofollow">https://youtu.be/k0yfiVhwG2w</a> And thanks to KeithCurtis for all your help!
1583654461
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Nice, clear, and elegant solution! I very much like this latest series.
1583673484
Nick O.
Forum Champion
Thanks, Keith!