Excel to gimp plugin/script?
#1
Posted 01 January 2010 - 05:38 PM
#2
Posted 03 January 2010 - 11:32 PM
#3
Posted 04 January 2010 - 12:14 AM
Quote
Anyway I believe you may found better tool then gimp to do thing with text,...gimp may do nice things with pixels but text are not made with pixels
(when text is converted in pixels gimp may come into play and create cool FX, but then txt info are automatically discarded and text become editable only as a image )
More i doubt actually gimp may deal with multi lines text...if you may select and copy from excel side the text one line at time then you may pass the text to gimp as input...
but if you hope Gimp able to automatically find the best size for the text to fill a box you risk delusion
it will make sense if you want some peculiar bitmap fx applied to your text or its background (but again that destroy all text data, after human may still read the text, but for the computer become a image.)
#4
Posted 04 January 2010 - 02:13 AM
I did some digging into GIMP batch processing and script commands. I see that an operation can be done to multiple images in a folder. Im thinking I could use the text command and figure out the locations/dimensions of each text box so that the text would always be in the correct places. The only thing I didn't come across is any file Input/Output commands for the scripting language, so that I could load and parse the data from the spreadsheet file. Is this something I missed or does it not exist?
Is there anyway to work around this? I have some programming knowledge, so given the functions I could figure it out, but Im not advanced enough to figure out how to get different programs to "talk" so to speak.
#5
Posted 04 January 2010 - 03:49 AM
If you provide further specifics and some example files then I'd be willing to assist.
Ideally, the Excel-produced text file should use space- or tab-delimited values (CSV can be made to work, but requires much more effort).
The image file(s) should be in XCF format and contain the graphic layer plus two layers which are the size and location of the regions where the text is to be placed.
#6
Posted 07 January 2010 - 01:59 AM
#7
Posted 11 January 2010 - 09:49 PM
#8
Posted 11 January 2010 - 10:20 PM
But are you sure the argument has to be kept private ?
Of course is your chose the PM feature is always available
#9
Posted 12 January 2010 - 07:48 AM
blackmesa5 said:
The path to each of the badge templates is specified in the data file (example.data). /home/username/badges is just an example directory, any directory could have been specified (in the data file).
Quote
Just send me a PM.
#11
Posted 20 January 2010 - 06:15 AM
In the data file I put columns to correspond with the template type, the two text boxes, the number box and the file name. The data for column 1 is the template file name/location, column 2 is the text to go in box 1, column 3 is the data to go in box 2, column 4 is the 2 digit number to go in the 3rd text box, and the final column is the desired filename. Does this make sense? Is it even possible?
Thanks so much for everything.
template: http://dl.dropbox.co...%20temp%201.xcf
data: http://dl.dropbox.co...52446/Book1.txt
#12
Posted 21 January 2010 - 03:28 AM
#13
Posted 07 February 2010 - 09:28 PM
Run the code from the command line with something like:
gimp -i -b "(process-excel-file \"C:\path\to\csv-file.txt\" \"C:\path\to\template-directory\\\" \"C:\path\to\output-directory\\\" )" -b "(gimp-quit 0)"
I don't run Windows so you may encounter problems.
(define (process-excel-file csv-filename template-path output-path)
(define (get-text-layer-with-name image name)
(let (
(layer's (vector->list (cadr (gimp-image-get-layers image))))
(layer 0)
)
(while (pair? layer's)
(set! layer (car layer's))
(if (and (gimp-drawable-is-text-layer layer)
(string=? (car (gimp-drawable-get-name layer)) name))
(set! layer's nil)
(begin
(set! layer's (cdr layer's))
(set! layer 0)
)
)
)
layer
)
)
(define (read-line inport)
(let* (
(ch (read-char inport))
(str "")
)
(while (and (not (eof-object? ch)) (not (equal? #\newline ch)))
(set! str (string-append str (make-string 1 ch)))
(set! ch (read-char inport))
)
(if (eof-object? ch)
nil
str
)
)
)
(let* (
(template 0)
(inport (open-input-file csv-filename))
(ch 0)
(line "")
(template-filename "")
(output-filename "")
(layer 0)
(field's nil)
)
(when inport
(read-line inport) ; skip first line
(set! line (read-line inport))
(while (not (null? line))
(set! field's (strbreakup line (make-string 1 #\tab)))
(set! template-filename (string-append template-path (car field's) ".xcf"))
(set! template (car (gimp-xcf-load 0 template-filename template-filename)))
(gimp-image-undo-disable template)
(set! layer (get-text-layer-with-name template "Text 1"))
(gimp-text-layer-set-text layer (cadr field's))
(set! layer (get-text-layer-with-name template "Text 2"))
(gimp-text-layer-set-text layer (caddr field's))
(set! layer (get-text-layer-with-name template "01"))
(gimp-text-layer-set-text layer (cadddr field's))
(set! output-filename (string-append output-path
(car (strbreakup (car (cddddr field's)) "\r"))
; ^^^ strip trailing MS-DOS RET ^^^
".xcf"))
(gimp-xcf-save 0 template layer output-filename output-filename)
(gimp-image-delete template)
(set! line (read-line inport))
)
(close-input-port inport)
)
)
)
#14
Posted 10 February 2010 - 02:43 AM
> gimp -i -b "(process-excel-file \"C:\Template\Book1.txt" \"C:Template\\\" \"C:\Template\\\" )" -b "(gimp-quit 0)"
Error: eval: unbound variable: gimp
#15
Posted 10 February 2010 - 05:34 AM
blackmesa5 said:
> gimp -i -b "(process-excel-file \"C:\Template\Book1.txt" \"C:Template\\\" \"C:\Template\\\" )" -b "(gimp-quit 0)"
Error: eval: unbound variable: gimp
That example was intended to be run from the Windows command prompt. If you are going to run the command from within GIMP's Script-fu console, you should use:
(process-excel-file "C:/Template/Book1.txt" "C:/Template/" "C:/Template/" )
Note that I replaced the backslashes with forward slashes -- Script-fu should automatically use the appropriate separator for your operating system.
#16
Posted 11 February 2010 - 02:59 AM
This is my template file http://dl.dropbox.co...52446/Book1.txt but I've also tried it with and without the .xcf after body (which is the template file) and also making the spread sheet a .csv file. It never returns anything other than "#t" nor does it make a file. I created the script file and named it exactly, "process-excel-file.scm".
Thanks for all this help!
#17
Posted 11 February 2010 - 03:41 AM
blackmesa5 said:
Your original data file had the headers in the first row (the script skips over the first line in the data file), and it also had a fifth column which contained the output filename (the script uses this filename).
Style Text 1 Text 2 Numbers Filename body temp 1 abcdefghi xyz 10 card1 body temp 2 xya abc 8 card2
#18
Posted 11 February 2010 - 08:25 PM
saulgoode said:
blackmesa5 said:
Your original data file had the headers in the first row (the script skips over the first line in the data file), and it also had a fifth column which contained the output filename (the script uses this filename).
Style Text 1 Text 2 Numbers Filename body temp 1 abcdefghi xyz 10 card1 body temp 2 xya abc 8 card2
Well that was a silly mistake. D'oh!
Just ran it, works P-E-R-F-E-C-T-L-Y! Thank you so much!
#19
Posted 18 February 2010 - 10:43 PM
(process-excel-file "C:/Template/Book1.txt" "C:/Template/" "C:/Template/Folder" )
It puts all finished files in the Template folder and adds "Folder" to the beginning of their filename. Not a huge deal, just wasnt sure if I was doing something wrong.
#20
Posted 19 February 2010 - 12:26 AM
blackmesa5 said:
(process-excel-file "C:/Template/Book1.txt" "C:/Template/" "C:/Template/Folder" )
It puts all finished files in the Template folder and adds "Folder" to the beginning of their filename. Not a huge deal, just wasnt sure if I was doing something wrong.
You need to have a solidus at the end of the folder paths:
- (process-excel-file "C:/Template/Book1.txt" "C:/Template/" "C:/Template/Folder/" )

Help













