tips to import images from pdf into VASSAL

I want to make a VASSAL module for a game where I have the material in pdf form. Is there a good way in Linux to chop the cards out of the pdf and create image files to use inside the VASSAL module? Or is there a way to just tell VASSAL what page number and area of the pdf from which to extract the image for a particular card?

You may want to invest some time investigating ImageMagick.

It can do what you want.

A more manual approach would be to use something like the gimp.

Both of these can handle PDF files.

  • M.

2009/5/6 IrishBouzouki < (>

Post generated using Mail2Forum (

Thus spake Michael Kiefte:

In the long-term, we need to find a PDF-rendering library so that we
can use PDFs directly.


Messages mailing list …

Post generated using Mail2Forum (

stupid me… I just opened the pdf in GIMP and voila an importer came up, letting me put the pages as separate layers. that lets me chop up the top layer to fit then I imagine I can export the layers as separate files, but I guess I have to do this for each card on the page.

I think that will work for the present application with only a few cards per page, an app with a hundred or so chits would be a mess this way however.

I saw ImageMagick when I was poking around. Will let you slice stuff up like you would for game counters or cards off a page?

actually I am not sure GIMP is what I want for this.

I do already have ImageMagick installed. Is there a tutorial for it somehwere that shows how a wargamer would set up a command for it to cut a countersheet image into images for individual counters, or whatever the equivalent nomenclature would be in the image world?

Gimp is very good at cutting counter sheets into individual images using the Slice filter (Under Filters → Web). You need Python and all this other gumpf installed before Gimp to get it enabled, which is a pain on Windows, but have a look here:

photocomix-resources.deviantart. … r-74889017


Messages mailing list …

Post generated using Mail2Forum (

The main manual is here:

I have to admit that the last time I did this, I used convert from a bash shell in Linux.

Here’s an example of what I’ve done. What I did here is convert two files from a photoshop image of a standard counter sheet, back and front. I then pull them out and then bevel the images. I know it looks evil, but if you can figure out how to do this, it’s a skill well worth learning:


#identify -format '%w' $BACK_NAME

if ! [[ -e $bumpmap ]]
convert -size $COUNTER_DIM xc:black -draw “fill white rectangle 3,3 $LR_CORNER_MXIII” -blur 0x$BLUR_STD -shade $SHADE $bumpmap
if ! [[ -e $rounded ]]
convert -size $COUNTER_DIM xc:none -draw “roundRectangle 0,0 $LR_CORNER_M $ROUNDING” $rounded

for (( j=0 ; j < 1 ; ++j ))
y=$(( (jDENSITY9+8)/16 + DENSITY/2 + j/2DENSITY/8 ))
for (( i=8 ; i < 11 ; ++i ))
x=$(( (i
DENSITY9+8)/16 + DENSITY/4 + i/9DENSITY*3/8 ))
if ! [[ -e $filename ]]
convert $FRONT_NAME[0–2] -crop $COUNTER_DIM+$x+$y +repage counters/counter.png
composite counters/counter.png $bumpmap -compose Overlay counters/unclipped.png
composite -compose Dst_In $rounded counters/unclipped.png $filename

    if ! [[ -e $filename ]] 
        echo $COUNTER_DIM $REVERSE_X $y
        convert $BACK_NAME[0--2] -crop $COUNTER_DIM+$REVERSE_X+$REVERSE_Y +repage counters/counter.png
        composite counters/counter.png $bumpmap -compose Overlay counters/unclipped.png
        composite -compose Dst_In $rounded counters/unclipped.png $filename
    echo "counter row = $j; column = $i"

#rm counters/{counter,unclipped}.png $bumpmap $rounded

Post generated using Mail2Forum (

Image->Transform->Guillotine seems to be a useful GIMP command. You set the guides first along the counter boundaries and it will slice and dice a sheet for you.

Of course you will be left with 200 or whatever images to save, but since they all get numbered it should not be terrible.

So I can tuck that one away for my pdf counter sheet to counter png requirement later because I think it will work. It will not be efficient on my computing but it seems like it will be relatively easy. Thanks.

For my current requirement I am still left with a set of 46-layer images, after guillotining the page into 9 sections along card boundaries (because I imported the 46-page pdf as separate layers instead of separate images). No idea how I am quite going to handle stripping the xcf down into separate pngs for each layer. Perhaps it is possible in GIMP to save a set of guides and use them quickly on multiple images without having to set them within each image?

I found and downloaded a script-fu file “sg-save-all-layers.scm” which supposedly does everything I want (takes my nine guillotined card xcf’s, one at a time, with 46 layers each and saves them each as 46 seperate png’s, or another format, sequentially numbering the output files).

But… I do not know anything about how to get the script to run in GIMP and I poked around and could not find a way right away to get the script to load up.

Sorry to ask… this is clearly not a VASSAL support question, but it is also something that might be useful to the ten people in the world who are trying to do something like this to create VASSAL modules, or at least the two or three are trying to but do not already know how.

If I did not start with such a huge number of pages in a pdf I would already be past this problem. Which is good for my project where I need to take the low-page-count pdf’s and make them into counter and map images. But for this one with the hundreds of pages of cards, geesh.

YouTube, amazing. Tells how to load a script-fu script in GIMP.

And, it works! I now have my guillotined cards separated into 9x46 png files and ready to load into a VASSAL module.

This should also help in any multi-page pdf import.

Thus spake “IrishBouzouki”:

Turn off all the layers except the one you’re working with. You don’t need
to modify the XCF file at all for that.


Messages mailing list …

Post generated using Mail2Forum (