PDA

View Full Version : Mass Resize of Tokens



JohnD
May 13th, 2013, 02:18
I have a large number of tokens I made by cutting from screenshots of a few computer games. I didn't have the presence of mind to ensure they were all made 50x50... is there any way I can do a mass re-size using an external program?

ddavison
May 13th, 2013, 04:09
ImageMagick does a good job of this. Here is a sample I use with a vb script that resizes all images with a keyword into a specific scale.

I recommend making extra copies of your original images because it is relatively easy to run a script that replaces all your images with modified versions. This one expects JPG incoming and PNG output. If you start with PNG files then you need to modify and make sure to output to another location.

This line does the work on each image and the rest just loops and spits them back out to various locations. The sample below tells ImageMagick to resize the image to 100x100 within a 100x100 square frame and replace the white background with transparency.

Credit for this goes to the smart folks on the download and resize all D&D tokens post. I've found the same technique to be useful a number of different occasions.



mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize 100x100 -background rgba(255,255,255,0) -type optimize -extent 100x100 "test.jpg" "test.png"

convert_images.bat

cd "%8"

mkdir Med-%3x%3

cd Original

dir *.jpg /B > miniList.txt

for %%f in (*_tiny.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %1x%1 -background rgba(255,255,255,0) -type optimize -extent %1x%1 "%%f" "%%f"

for %%f in (*_small.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %2x%2 -background rgba(255,255,255,0) -type optimize -extent %2x%2 "%%f" "%%f"

for %%f in (*_medium.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %3x%3 -background rgba(255,255,255,0) -type optimize -extent %3x%3 "%%f" "%%f"

for %%f in (*_large.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %4x%4 -background rgba(255,255,255,0) -type optimize -extent %4x%4 "%%f" "%%f"

for %%f in (*_huge.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %5x%5 -background rgba(255,255,255,0) -type optimize -extent %5x%5 "%%f" "%%f"

for %%f in (*_gargantuan.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %6x%6 -background rgba(255,255,255,0) -type optimize -extent %6x%6 "%%f" "%%f"

for %%f in (*_colossal.jpg) do mogrify -format png -fuzz 10%% -transparent white -gravity center -filter lanczos -resize %7x%7 -background rgba(255,255,255,0) -type optimize -extent %7x%7 "%%f" "%%f"

move *.png ..\Med-%3x%3



convertDirectory.vbs


Option Explicit

Dim objShell
Set objShell = CreateObject("WScript.Shell")

Dim pixelSizeT
Dim pixelSizeS
Dim pixelSizeM
Dim pixelSizeL
Dim pixelSizeH
Dim pixelSizeG
Dim pixelSizeC

pixelSizeT = 30
pixelSizeS = 40
pixelSizeM = 50
pixelSizeL = 100
pixelSizeH = 200
pixelSizeG = 400
pixelSizeC = 800
resizeImages("MyImageDir")

WScript.Echo "Done resizing images"

Sub resizeImages(Directory)

objShell.run "cmd /C convert_images.bat " & pixelSizeT & " " & pixelSizeS & " " & pixelSizeM & " " & pixelSizeL & " " & pixelSizeH & " " & pixelSizeG & " " & pixelSizeC & " " & Chr(34) & Directory & Chr(34), 1, True

End Sub

phantomwhale
May 13th, 2013, 05:46
+1 for ImageMagick - srcipted with whatever language floats your boat (I wrote a Windows Batch file to resize module images using this technique).

Photoshop (and presumably GIMP) also has a bulk actions tool, so you can define a macro to resize and save an image, and then play it over a whole folder. I always muck up one or two things when I do this, so take backups, but it requires less programming knowledge, if you aren't familiar with scripting languages

gmkieran
May 13th, 2013, 14:25
I've never gotten ImageMagick to work, but I don't script and I don't understand the scripts that have been presented for using it. Windows PowerTool image re-sizer seems to be a fine, free and intuitive tool for this, but I haven't found a version for Win8, yet.

Valarian
May 13th, 2013, 19:30
Faststone photo resizer .. great tool.

JohnD
May 13th, 2013, 19:45
Count me in the "don't understand the scripts" column. Thanks for the info... was hoping Irfranview or something like that might have something.

Although FastStone looks promising... thanks!

Trenloe
May 13th, 2013, 20:15
Thanks for the info... was hoping Irfranview or something like that might have something.
https://lmgtfy.com/?q=irfanview+batch+resize

See the second result.

JohnD
May 13th, 2013, 20:42
LOL thanks Trenloe... I will take a look.

Griogre
May 14th, 2013, 19:26
I use Irfanview for batch resizing a fair amount - but unless they changed it in a recent version - it doesn't handle tokens with transparency. So it'll do fine with "pogs" but not with top down or side view tokens with transparent parts.

JohnD
May 14th, 2013, 22:23
Fine for me... I prefer the pog style.

Invictys
May 14th, 2013, 22:31
+1 for FastStone resizer

It's free, can do all kinds of batch processing, handles transparency if needed and many different input/output formats, and it's easy to use

https://www.faststone.org/FSResizerDetail.htm

Ikaris
January 5th, 2014, 17:28
I use PicSizer from AxiomX (It's free too).

https://www.axiomx.com/picsizer.htm

That has a lot of nice features and no scripting is required.

Blacky
January 6th, 2014, 08:19
Photoshop does this, but it's quite expensive. And the batch tool is, for a software of this price, very user unfriendly and not very powerful. The advantage is if you do your work with it, the overall quality rendered is probably better (since it works with source files, can smart scale styles and mask, and so on); although for VTT tokens and the usual work process this doesn't apply.

Imagemagick is the image format manipulation tool. Yes it requires its documentation read, and has no batch capability (it assumes other things do the batch, like any unix OS can natively since the dawn of time). But it's by far the most powerful tool there is for things like that (almost every server out there, any website that does image manipulation uses it or an ersatz).

For not-geek people, things like Faststone and Picsizer should work fine.

seycyrus
January 11th, 2014, 14:51
I've found this thread and the older one about image resizing to be very useful. I've tried working with Faststone for batch resizing, but can't get it to preserve the transparency. Does anyone have any pointers?

Edit: I see I can get a transparency effect by working with the watermark option. I suppose I could just give it an empty file as a watermark, but is there a better option?

Edit 2: I think I found a better solution, which is to select the "Paeth" filter under the "settings" tab.

Ikaris
January 11th, 2014, 17:08
I've found this thread and the older one about image resizing to be very useful. I've tried working with Faststone for batch resizing, but can't get it to preserve the transparency. Does anyone have any pointers?

Edit: I see I can get a transparency effect by working with the watermark option. I suppose I could just give it an empty file as a watermark, but is there a better option?

Edit 2: I think I found a better solution, which is to select the "Paeth" filter under the "settings" tab.

I'm certainly no expert at using FastStone, but I have used it's batch conversion tool to resize a bunch of my .png files and it seems to preserve the transparency just fine for me (I didn't touch the filter setting which was set to "Lanczos3").

I tried using FastStone to convert my png to jpg and it cannot preserve the transparency when doing that. Same with GIMP. So it may be just the way these tools work with jpg. I've seen some people claim that jpg can't support transparency and other claim that it can. But apparently not all tools can utilize the transparency on jpg images.

JohnD
January 11th, 2014, 17:14
Yeah I'm glad I asked the question; seems I'm not the only one that had it. :)

Lots of good suggestions here!