PDA

View Full Version : D&D Miniatures Resizing Script



tdewitt274
April 12th, 2010, 13:22
This script was based off of work done by "valeros". The original can be found here (https://www.fantasygrounds.com/forums/showthread.php?t=10812).

The included script is designed to download images files from a website (in this case, WotC's D&D Mini Preview pages), convert the files to PNG and remove the originals.

BE AWARE: The VBScript file (ending in VBS) uses features that some antivirus programs may consider the file to be a virus. You may view the details of the file by editing the file as described in the "Before Running" section.

Before Running
================================================== ========

ImageMagic needs to be installed on the system.

This script has been tested with ImageMagick 6.5.7 for Windows
https://www.imagemagick.org/

You must configure the "START UPDATE" sections in the file.

To edit, right click the file and choose "Open With..." and choose "Notepad" or another text editor.
Version 1

Line 17

Change the location to where you would like to store the files.
The location must be enclosed in quotation marks.
The location must end in a \
Example:


CurrLoc = "C:\Downloaded Files\Fantasy Grounds\tokens\"


Line 19

Change the location to where ImageMagick is located.
The location must be enclosed in quotation marks.
The location must end in \convert.exe
Only change the location of the line (In the example below, c:\program files\ImageMagick-6.5.7-1)
Example:


ConvertLoc = chr(34) & "c:\program files\ImageMagick-6.5.7-1\convert.exe" & chr(34) & " "


Line 46 & 47

If you would like to keep the original JPG files that were downloaded, put an apostraphe (') before the text on these lines.
Example 1:


'AddToBatchFile("PING -n 20 127.0.0.1>nul")
'AddToBatchFile("DEL " & chr(34) & CurrLoc & arySets(i,0,SysNum) & "\*.jpg" & chr(34))

Example 2:


' AddToBatchFile("PING -n 20 127.0.0.1>nul")
' AddToBatchFile("DEL " & chr(34) & CurrLoc & arySets(i,0,SysNum) & "\*.jpg" & chr(34))






To Run
================================================== ========

Extract the files.
Double Click on the "DownloadAndResize.vbs" file.
When prompted, enter the size of the of the Medium sized pixel.
After all files are downloaded, you will be notified and a DOS box will populate to modify the file.
When the DOS box goes away, the files are complete.
The images will be located in the folder on Line 17.


Version 1 Features:
================================================== ========

Saves downloaded images to a folder created for each set of miniatures.
Modifies background to remove white space.
Resizes the images based on the size of the creature (ex, Small is 0.75x the size of Medium, Large is 2x the size of Medium)
Currently configured for 3.x Edition
Includes the following sets:

Set Symbols
Harbinger
Dragoneye
Archfiends
Giants of Legend
Aberrations
Deathknell
Angelfire
Underdark
War Drums
War of the Dragon Queen
Blood War
Unhallowed
Night Below
Desert of Desolation
Dungeons of Dread
Against the Giants
Demonweb
Players Handbook Heroes Series 1
Dangerous Delves
Legendary Evils
Players Handbook Heroes Series 2
Savage Encounters



Any feedback is appreciated!

EDIT: Original file did not download the files due to testing bug. This has been fixed in the current attachment.

Czarisyn
April 12th, 2010, 13:48
Downloading does not start after entering the pixels

tdewitt274
April 12th, 2010, 14:09
Downloading does not start after entering the pixels

Doh! Thanks! I disabled the last piece while testing. You can either download the file again or remove the apostraphe from line 1460 so that it says Call StartDownloading

Thanks!

Czarisyn
April 12th, 2010, 14:43
worked nicely, good work

tdewitt274
April 14th, 2010, 14:40
Here's a newer version that will set everything up for making your own modules.

Previously noted lines have been changed to account for new code. Please review the "READ ME.TXT" file in the zip folder for details.


Adds a "definition.xml" and "thumbnail.png" (using the set name, where available from the WotC website) file for module creation.
Moves the files to a \[Set Name]\tokens\[Set Name] format to allow for module creation.

To create the module, go into the \[Set Name]\tokens folder and select all files, add to your favorite zipping utility.
Rename as appropriate, with the extention ".mod" instead of ".zip"

Modified code to handle new features.


Any feedback is appreciated!

tdewitt274
April 15th, 2010, 03:33
The script now creates a Module (MOD) file for each set. After the scripting is completed, copy the Module to your "modules" folder for Fantasy Grounds.

See the screen shot for an example of the finished product.

Previously noted lines have been changed to account for new code. Please review the "READ ME.TXT" file in the zip folder for details.

EDIT: Updated the ZIP file to resolve the War Drums and Night Below thumbnails show in the modules.


Line 306
aryNames(0,0,11,0) = "ddm_setsymbol_11.jpg,Blood War.jpg,M"
Line 308
aryNames(0,0,13,0) = "ddm_setsymbol_13.jpg,Night Below.jpg,M"

Czarisyn
April 20th, 2010, 21:35
tried version 3, the mod file doesn't get made, I do see a definition file and a zip file though

tdewitt274
April 21st, 2010, 00:25
tried version 3, the mod file doesn't get made, I do see a definition file and a zip file though

There's another thread same name as this one with "Problem") that I've been working through the issue. If you scroll to the bottom, I have a solution that has worked for me.

Sorry, I'm on a mobile phone and can't provide the link.

tdewitt274
April 22nd, 2010, 02:48
Thread on troubleshooting an issue with the v003 script. (https://www.fantasygrounds.com/forums/showpost.php?p=89291&postcount=15)

I'll post a more permanent solution when available.

tdewitt274
April 22nd, 2010, 03:34
A new version has been posted. This is pretty much the same as the previous version, with a few enhancements, code revisions, and a bug fix.

Dialog boxes are now used instead of modifying the actual script file. Please see the below instructions of how to run the script (also included in the Read Me text file).


Extract the files.
Double Click on the "DownloadAndResize.vbs" file.
You will be asked to choose a folder for saving the files.

Navigate to the folder desired.
If the folder does not exist, you can create a "New Folder" by clicking the "New Folder" and typing a name.

The system will automatically determine the location of ImageMagick.

If ImageMagick is not found automatically, you will be prompted to find the "convert.exe" file.

Navigate to the folder location of ImageMagick and double click on the "convert.exe" file.


When prompted, enter the size of the of the Medium sized pixel.
After all files are downloaded, you will be notified and a DOS box will populate to modify the file.
When the DOS box goes away, the files are complete.
The images will be located in the folder chosen at the begining of the script.
Copy the created Module (MOD) files to your "module" folder for Fantasy Grounds.


Let me know if you encounter any issues.

Thanks

00Kevin
May 6th, 2010, 23:28
Hi,

I've tried to use the modules your script created, but I haven't had any luck. I can load the modules, but I don't see them being added to the token screen.

Also I've noticed that if i put the pictures the program downloads into the tokens folder they show up with white backgrounds and not transparent backgrounds like you have in the example screenshot.

Finally, what size do you recommend using?

tdewitt274
May 7th, 2010, 04:07
Hi,

I've tried to use the modules your script created, but I haven't had any luck. I can load the modules, but I don't see them being added to the token screen.

This should create a token bag with the minis inside it.


Also I've noticed that if i put the pictures the program downloads into the tokens folder they show up with white backgrounds and not transparent backgrounds like you have in the example screenshot.

Can you post a screen shot so I can see? Also, what version of ImageMagick do you have?


Finally, what size do you recommend using?
That's a big debate. I've heard a range of different numbers. One thing to keep in mind is that the bigger the pixel size, the longer it takes to load. You can mess around with different sizes by moving the modules into another directory (so you don't lose them) and running the script again.

I'll have to consider a way to re-run the script if you only want to resize them.

00Kevin
May 8th, 2010, 23:59
ImageMagick-6.6.1-7-Q16-windows-dll.exe is the version i installed. I'll try the older one.

I can confirm that when I load the module from the menu it doesn't create a token bag.

The other problem I had with the images showing white backgrounds was my fault (I copied the wrong images to the folder).

tdewitt274
May 9th, 2010, 01:14
The other problem I had with the images showing white backgrounds was my fault (I copied the wrong images to the folder).

I'm not sure I understand this one. The script should automatically create the Modules (see attached image). These should be copied to your "modules" folder in your Application Data directory for Fantasy Grounds.

Thanks

00Kevin
May 9th, 2010, 17:57
I finally got this to work after i re-installed ImageMagick. The modules were created and they work in FG2

tdewitt274
May 9th, 2010, 18:08
I finally got this to work after i re-installed ImageMagick. The modules were created and they work in FG2
Good to hear. I'll see if I can reproduce the issue when I get a chance.

Zulithe
July 8th, 2010, 14:26
This script is not working for me. I am using Windows 7 64bit w/ all Windows Updates installed, ImageMagick-6.6.2-10-Q16-windows-dll installed to default location of C:\Program Files (x86)\ImageMagick-6.6.2-Q16

I get a Windows Script Host error pop-up after being prompted to select the location of my convert.exe (the box to select it never pops up, instead I get this):

Script:
C:\<filelocation>\DownloadAndResize.vbs
Line: 42
Char: 2
Error: ActiveX component can't create object:
'SAFRCFileDlg.FileOpen'
Code: 800A01AD
Source: Microsoft VBScript runtime error

I thought it might be some kind of Permissions issue. I tried running cmd.exe as admin and launching the script from there. I get the same error. Any help?

tdewitt274
July 9th, 2010, 05:13
This script is not working for me. I am using Windows 7 64bit w/ all Windows Updates installed, ImageMagick-6.6.2-10-Q16-windows-dll installed to default location of C:\Program Files (x86)\ImageMagick-6.6.2-Q16

Just to confirm, you are using version 4 above, correct?

I'll take a look and see what could be happening.

EDIT: I think I found the problem. I'm assuming that all Windows OS are using "C:\Program Files" for the location of the Programs. However, as you've stated, you have "C:\Program Files (x86)" for yours. Is this a user defined or application defined folder?

In the mean time, update Line 31 from
Set objFolder = objFSO.GetFolder("C:\Program Files")
to
Set objFolder = objFSO.GetFolder("C:\Program Files (x86)")

This should resolve the problem. If you can answer my above question, I can error handle it for future reference.

Thanks!

Zeus
July 9th, 2010, 08:02
tdewitt274 -Windows 7 implements the following as standard folders:

C:\Program Files\ - 64bit executables
C:\Program Files (x86)\ - x86 32bit executables

The architecture build type the app is compiled against will determine which location the app will be installed to.

tdewitt274
July 9th, 2010, 14:34
Hmm, that being the case, I'll need to do a little more work. However, the above workaround will work for now.

Thanks, Dr!

Zulithe
July 10th, 2010, 00:37
Thanks guys. tdewitt274, the change for line 31 worked like a charm.

A couple small suggestions:

I noticed that the modules puts each set into a subfolder within its own parent folder. For example, after loading the War Drums module, I open my token box, and I see a War Drums 'bag'. But when i click to open it, there is another bag inside I have to click. Why two bags?

Second, how about an option to create a single module that has ALL the minis inside, separated by set? I imagine most people using this script will want all of the minis available, so having each set as its own module may not be necessary for these users.

Anyway, thank you!

Now if I can just decide on a baseline size for my medium creatures... it seems most people are using 100?

tdewitt274
July 11th, 2010, 17:16
I noticed that the modules puts each set into a subfolder within its own parent folder. For example, after loading the War Drums module, I open my token box, and I see a War Drums 'bag'. But when i click to open it, there is another bag inside I have to click. Why two bags?

I must have added something after the fact and just didn't check it. I'll take a look and see what I can do.
EDIT: Yes, I remember why now. If you choose to have the original JPGs saved, the files still reside in the same folder. As a result, anyone choosing to keep the original JPG images will have images in the main folder and then in the "Set Folder". I'll look at moving this around in some way, but it may not be this version.



Second, how about an option to create a single module that has ALL the minis inside, separated by set?

I'll take a look at this as well. Since I have most everything there, it seems like it would be a simple enough task. No gaurantees ;)



Now if I can just decide on a baseline size for my medium creatures... it seems most people are using 100?
The video tutorials seem to suggest a square size of 50 pixels. So, it will depend on what you set your maps to for ease of use. However, you can scale them, so it may not make a difference.

tdewitt274
July 11th, 2010, 18:44
Zulithe, could you try the attached file?

This should resolve the below issues:

Nested folder issue
JPG Backup (related to the above issue)
Windows 7 "Program File" folder changes


If everything works correctly, I'll upload the new version.

Zulithe
July 11th, 2010, 21:01
Thank you. It works. both the windows 7 and nested folder issues are gone for me in v5_BETA. However, after the modules are created it tells me it is converting the images. but i assume it already did that :P

Much appreciated. I am experimenting with both 50px and 100px. I think 50 may be a little small for my taste. Guess I'll have to try a third pass at 75px and see how that looks.

Still crossing my fingers for that all-in-one module. :) I'm sure I could figure a way to edit them all together myself, but others may also like the feature.

tdewitt274
July 11th, 2010, 21:42
Thank you. It works. both the windows 7 and nested folder issues are gone for me in v5_BETA.

Thanks for the feedback and testing!


However, after the modules are created it tells me it is converting the images. but i assume it already did that :P

It's some legacy code, but still actually serves a purpose for notification purposes so I left it in.


Still crossing my fingers for that all-in-one module. :) I'm sure I could figure a way to edit them all together myself, but others may also like the feature.
I'll take a look when I get more of a chance.

Any suggestions how you want to see it? With the considerable amount of images, it might be a good idea to keep them in their folders.

I have thought about adding "tags" to them (undead, goblin, etc), but that would be a considerable effort to figure out what everything is and isn't.

Zulithe
July 12th, 2010, 10:52
If it were to be done, I think having each set in its own folder inside the module would be best.

As you said, I would love to see them sorted into bags by creature type but that may be dreaming a little too hard :P

In a perfect world I think a 'tag' system where you can assign multiple tags to each mini would be awesome. Like say a creature that is a minotaur, evil alignment, large, part of miniature set X, etc., would appear in all of the appropriate bags while the module itself only needs to contain 1 copy of the actual image.

I have no idea if something like this is even possible with the current system

tdewitt274
July 12th, 2010, 14:20
If it were to be done, I think having each set in its own folder inside the module would be best.

As you said, I would love to see them sorted into bags by creature type but that may be dreaming a little too hard :P

This would likely be a possibility. I'll have a look again when I get more time.


In a perfect world I think a 'tag' system where you can assign multiple tags to each mini would be awesome. Like say a creature that is a minotaur, evil alignment, large, part of miniature set X, etc., would appear in all of the appropriate bags while the module itself only needs to contain 1 copy of the actual image.

I have no idea if something like this is even possible with the current system
The way I have things set up, it's probably an option with a few changes (like changing "," to ";", and there's a lot of those in sensative places). The issue is that it takes so long to add the tags and to add them correctly. The Warband Generator may be able to be used, but not all minis are supported (namely, the 4e items).

Zulithe
July 12th, 2010, 18:00
Oh, yes. Well playing a fair bit of 4E myself, it would be nice if it were as compatible as possible with that system. But again, this is just one person's thoughts... you're the one doing the work :P

Though if there is any way that I can assist feel free to let me know how. Maybe I could help with the tagging in some way, after it is agreed just which tags we would use.

Jundle
September 15th, 2010, 19:02
I have run the v5_BETA you put out and it's AWESOME, thank you! I have a few questions about the file outputs and what I'm supposed to do with them.

I placed the output of the "job" into a folder called "test2". Inside "test2" I have a bunch of sub-folders, a resize bat file, and a bunch of .mod files.

Inside the subfolders, I have a definition.xml file, a single .png called "thumbnail", and a "tokens" folder. Inside the tokens folder is the rest of the respective .png tokens.

My questions are these:

What are the .mod files for? What are the definition.xml files for? What is the thumbnail.png for? Also, what folder(s) do the .mod files, definition.xml files, thumbnail.png's, and the actual .png tokens go into so that Fantasy grounds can read them? And, do I have to copy these files to each client computer as well, or can the GM client instance "push" the tokens to the clients?

tdewitt274
September 16th, 2010, 00:37
The quick answer would be the MOD files are used by FG to contain the minis for the set. Open the module and you have the minis available. The minis will then be viewable by the clients when put on a map.

The other files are what the script uses while processing, and can be deleted if desired.

Edit: The longer version (sorry, previously on a cell phone):

What are the .mod files for? The MOD files can be added to the "Application Data\Fantasy Grounds II\modules" folder and accessed as Modules within the game. This reduces the download time for the clients as you are adding them after you load the ruleset.
What are the definition.xml files for? These are used for creation of the Module.
What is the thumbnail.png for? For the sets that have an icon for the mini set, an Icon is created to be shown in the Module window.
Also, what folder(s) do the .mod files, definition.xml files, thumbnail.png's, and the actual .png tokens go into so that Fantasy grounds can read them? The "Application Data\Fantasy Grounds II\modules" folder.
And, do I have to copy these files to each client computer as well, or can the GM client instance "push" the tokens to the clients? Up to you, but I suggest no. If you copy the folders to the "tokens" folder, it will dramatically increase the amount of files that are downloaded to the client. Since these are usually only available for the GM, it's really not a good idea. Stick with the modules and you'll be fine.

In the long run, the files are left there for your reference. If you want to make your own, you don't have to download and resize them, as it's already done. You can modify the script to remove/keep the original JPG files, see the "READ ME" text file.

The "resize.bat" is used to execute the Command Line interface. You can delete it if you like, the script will do that automatically the next time it is run.

Hope this helps!

Thanks

tdewitt274
October 19th, 2010, 03:34
Version 6 Features:

Added Lords of Madness minis.
Fixed the link to the Harginger set.


Edit: There was an issue with some of the code and images, these have been fixed in the attached file.

valeros
October 20th, 2010, 06:29
I had to change the three loops from 22 to 23 to get Lords of Madness.

tdewitt274
October 21st, 2010, 02:46
I had to change the three loops from 22 to 23 to get Lords of Madness.

Thanks, I've fixed the issue and a couple of other things. Shouldn't have the issue in the future.