09-04-2022, 12:35 PM
I test Imagemagick to but finaly I made with a script-fu and Gimphried help (thanks again).
Because I need reverse date format at begin of each file this is my final script.
So I change just size, font, color, position and output file name (remove the counter).
Perfect for me with an img2pdf script after to have both image and pdf files.
Because I need reverse date format at begin of each file this is my final script.
So I change just size, font, color, position and output file name (remove the counter).
Perfect for me with an img2pdf script after to have both image and pdf files.
Code:
(define (WriteDate path-in template ext date counter)
(let* ( (filePoster (string-append path-in DIR-SEPARATOR template ext))
(strIdx (number->string counter))
(strZidx (if (< counter 10) (string-append "0" strIdx) strIdx))
(path-out (string-append path-in DIR-SEPARATOR "target" DIR-SEPARATOR))
(file-out (string-append path-out strIdx "_" template ext))
(posX 380) (posY 480)
(imgDat (car (gimp-image-new 1 1 RGB))) ; Empty poster
(layerDat (car (gimp-layer-new imgDat 1 1 RGB-IMAGE "layer_date" 100 LAYER-MODE-NORMAL-LEGACY)))
)
(gimp-image-insert-layer imgDat layerDat 0 0)
(gimp-context-set-foreground '(255 255 255)) ; white
(gimp-context-set-background '(255 255 255)) ; white
(gimp-drawable-fill layerDat BACKGROUND-FILL) ; Empty white poster
(let* ((layerPoster (car (gimp-file-load-layer 1 imgDat filePoster)))) ; load template
(gimp-image-insert-layer imgDat layerPoster 0 0) ; as a layer to the empty poster
(script-fu-util-image-resize-from-layer imgDat layerPoster) ; same size than the template
(gimp-layer-resize-to-image-size layerDat)
(display "file-out: ") (display file-out) (display " date: ") (displayln date)
; Write the date in posX, posY Sans font (private joke)
(let* ((layerTxt (car (gimp-text-fontname imgDat layerPoster posX posY date 0 TRUE 40 POINTS "DejaVu Sans Bold"))))
(gimp-floating-sel-anchor layerTxt)
) ) ; Anchor the floating selection to its associated drawable
(let* ((layerSav (car (gimp-image-flatten imgDat)))) ; Save the dated poster
(gimp-displays-flush)
(gimp-file-save RUN-NONINTERACTIVE imgDat layerSav file-out file-out)
(gimp-image-delete imgDat)
) ) )
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "6 Oct. 2022" 20221006)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "20 Oct. 2022" 20221020)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "17 Nov. 2022" 20221117)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "1 Déc. 2022" 20221201)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "15 Déc. 2022" 20221215)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "12 Jan. 2023" 20230112)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "26 Jan. 2023" 20230126)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "9 Fév. 2023" 20230209)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "2 Mars 2023" 20230302)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "16 Mars 2023" 20230316)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "30 Mars 2023" 20230330)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "13 Avr. 2023" 20230413)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "4 Mai 2023" 20230504)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "25 Mai. 2023" 20230525)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "8 Juin 2023" 20230608)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "22 Juin 2023" 20230622)
(WriteDate "/home/carl/Images/Hibou/" "Jazz au Hibou" ".png" "6 Juil. 2023" 20230706)