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! :)
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! :)
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?
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. :)
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.
That might be a good excuse to introduce adding options to an API:
!mapSizer --units 20 20
!mapSizer --pixels 1400 1400
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?
I think it's just convention, but the Aaron would probably be the person to ask. It's certainly not universal.
Just posted part 2 of the vid, which covers how further enhance the script so it lets the user specify units or pixels https://youtu.be/k0yfiVhwG2w
And thanks to KeithCurtis for all your help!