Saturday, July 05, 2008

Convert PDF to PNGs with The GIMP

Task: Convert the maps from from 2d EVEMaps to png images which can view viewed with the ingame browser.

You'll need GIMP for this.

  1. start GIMP
  2. open the Script-Fu console via Extras -> Script-Fu -> Script-Fu-console
  3. copy & paste the code below into the console, press enter
  4. open the pdf, set the options as you like but set Open pages as to images. To test it select only a few maps.
  5. copy & paste (export-all-as-png 1) in to console, press enter

The images will be saved as c:\eve-regions\eve-region-1.png, if you don't like that change the code

(define (export-all-as-png start)
  (define (loop l i)
    (let ((image (car l))
          (name (string-append "c:\\eve-regions\\eve-region-"
                               (number->string i)
                               ".png")))
      (gimp-image-convert-indexed image 0 0 255 0 0 "")
      (file-png-save 1
                     image
                     (car (gimp-image-active-drawable image))
                     name
                     name
                     0
                     4
                     0 0 0 0 0)
      (gimp-image-clean-all image))
    (if (not (null? (cdr l)))
        (loop (cdr l) (+ i 1))
      i))
  (let ((images (reverse (vector->list (cadr (gimp-image-list))))))
    (loop images start)))

1 comment:

Anonymous said...

Thank you: you have save me!
Point 5: copy and past the following line into the console

(export-all-as-png 1)

THANK YOU!