Vous êtes sur la page 1sur 9

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; SCRIPT-FU-BATCH-INTERNET-PUBLISH ; ; Copyright (c) 2012 Felipe Carvalho <www.felipe-carvalho.com> ; ; version 1.00 2012.07.02 for Gimp 2.8.

0 ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;;;LICENSE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;This program is free software; you can redistribute it and/or modify it; ;under the terms of the GNU General Public License as published by the Free; ;Software Foundation; either version 2 of the License, or (at your option) any; ;later version. ; ; ; ;This program is distributed in the hope that it will be useful, but WITHOUT; ;ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS; ;FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.; ; ; ;You should have received a copy of the GNU General Public License along with; ;this program; if not, write to the Free Software Foundation, Inc., 51 Franklin; ;Street, Fifth Floor, Boston, MA 02110-1301, USA. ; ; ; ;Copy of the license available at http://www.gnu.org/copyleft/gpl.html ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;;;SOURCE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;This program makes use of the following programs in order to apply watermarks:; ;- script-fu-watermark-batch version 1.02, by Tharsice Demand <www.td-e.com> ; ; - Script was merged into this one, with parts of the original code left; ; unchanged. ; ;- script-fu-watermark-it version 1.00, by Tharsice Demand <www.td-e.com> ; ; - Script is used without changes to the original code. ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; ; ;;;ABOUT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;- In other to prepare your pictures for publishing in the internet, this; ; script may: ; ; - Resize your image (downsize) for better web viewing experience ; ; - A set of predefined sizes are avaialable ; ; - The selected size will be applied to the largest dimension (width or; ; height) ; ; - Apply a watermark to protect your content ; ; - The watermark may be a simple text; or ; ; - It may be a image (follow tutorial on http://www.scottphotographics.; ; com/how-to-make-a-simple-watermark-in-gimp/) ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;;;INSTRUCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;- You need to download the watermark scripts mentioned above from Tharsice; ; Demand <http://www.td-e.com> and install it on your system ; ;- Install this script (Internet Publish) ; ;- Run the script: Filters -> Batch -> Internet Publish ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;;;WARNING;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;- I have not tested this script thoroughly enough. So Please test it first; ; with a set of images that you have backed up. ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;;;To do in future releases:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ;- add option for the different resizing sampling modes ; ;- add check to ensure src and dest dirs are different if overwrite is not; ; checked. ;

; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (script-fu-batch-internet-publish inOS inSrcPath inMatchFile inOverwrite inDestPath inApplyWM inWmFile inXMarginI inYMarginI inOpaI inWmText inXMarginT inYMarginT inOpaT inOpaTb inWmFont inWmFontSize inWmFontColor inWmNoColor inWmEmboss inTopLef inTopRig inBotLef inBotRig inCentered inApplyRsz inMaxSizeType) ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message ;(gimp-message (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append (string-append "inOS: " (number->string inOS))) "inSrcPath: " inSrcPath)) "inMatchFile :" inMatchFile)) "inOverwrite: " (number->string inOverwrite))) "inDestPath :" inDestPath)) "inApplyWM :" inApplyWM)) "inWmFile :" inWmFile)) "inXMarginI :" inXMarginI)) "inYMarginI :" inYMarginI)) "inOpaI :" inOpaI)) "inWmText :" inWmText)) "inXMarginT :" inXMarginT)) "inYMarginT :" inYMarginT)) "inOpaT :" inOpaT)) "inOpaTb :" inOpaTb)) "inWmFont :" inWmFont)) "inWmFontSize :" inWmFontSize)) "inWmFontColor :" inWmFontColor)) "inWmNoColor :" inWmNoColor)) "inWmEmboss :" inWmEmboss)) "inTopLef :" inTopLef)) "inTopRig :" inTopRig)) "inBotLef :" inBotLef)) "inBotRig :" inBotRig)) "inCentered :" inCentered)) "inApplyRsz :" inApplyRsz)) "inMaxSizeType :" inMaxSizeType))

; ; ; ;

(let* ( ("1920 (Full_HD)" "1600 (UXGA)" "1280 (720p_HD-WXGA)" "1024 (XGA)" "800 (SVGA)" "640(VGA)") (inMaxSize (if (= inMaxSizeType 0 ) 1920 (if (= inMaxSizeType 1 ) 1600 (if (= inMaxSizeType 2 ) 1280 (if (= inMaxSizeType 3 ) 1024 (if (= inMaxSizeType 4 ) 800 640 ) ) ) ) ) ) (theSeparator (if (= inOS 0) "\\" "/")) (theMatchFilter (if (not (null? inMatchFile)) inMatchFile "*")) (theMatchFilter inMatchFile) (thePathPattern (string-append inSrcPath theSeparator theMatchFilter)) (theFileList (cadr (file-glob thePathPattern 1))) ) (gimp-message (string-append "inApplyWM: " (number->string inApplyWM))) (gimp-message (string-append "theSeparator: " theSeparator)) (gimp-message "here") (gimp-message (string-append "theFileList: " (car theFileList))) (while (not (null? theFileList)) (let*

( (theFileName (car theFileList)) (theDirs (strbreakup theFileName theSeparator)) (theDepthOfPath (length theDirs)) (theShortFileName (nth (- theDepthOfPath 1) theDirs)) (theDestFileName (if (= inOverwrite 0) (string-append inDestPath theSeparator theShortFileName) theFileName)) (theImageList (gimp-file-load RUN-NONINTERACTIVE theFileName theFileName)) (theImage (if (not (null? theImageList)) (car theImageList) 0)) ) (if (= inApplyRsz 1) (let* ( (theDrawableList (gimp-image-get-active-layer theImage)) (theDrawable (if (not (null? theDrawableList)) (car theDrawableList) 0)) (theWidth (car (gimp-image-width theImage))) (theHeight (car (gimp-image-height theImage))) (theRatio (if (> theWidth theHeight) (/ inMaxSize theWidth) (/ inMaxSize theHeight) ) ) (theNewWidth (if (< theRatio 1) (round (* theRatio theWidth)) 1)) (theNewHeight (if (< theRatio 1) (round (* theRatio theHeight)) 1)) ) (if (> theDrawable 0) (begin ; (gimp-message (string-append "theDestFileName: " theDestFileName)) ; (gimp-message (string-append "theDrawable: " (number->string theDrawable))) (gimp-image-undo-disable theImage) (gimp-image-scale-full theImage theNewWidth theNewHeight INTERPOLATION-LANCZOS) ; (gimp-file-save RUN-NONINTERACTIVE theImage theDrawable theDestFileName theShortFileName) )

) ) ) (if (= inApplyWM 1) (let* ( (theDrawableList (gimp-image-get-active-layer theImage)) (theDrawable (if (not (null? theDrawableList)) (car theDrawableList) 0)) ) (if (> theDrawable 0) (script-fu-watermark-it theImage theDrawable inWmFile inXMarginI inYMarginI inOpaI inWmText inXMarginT inYMarginT inOpaT inOpaTb inWmFont inWmFontSize inWmFontColor inWmNoColor inWmEmboss inTopLef inTopRig inBotLef inBotRig inCentered ) ; (gimp-file-save RUN-NONINTERACTIVE theImage theDrawable theDestFileName theShortFileName) ; (gimp-image-delete theImage) ) ) ) (let* ( (theDrawableList (gimp-image-get-active-layer theImage)) (theDrawable (if (not (null? theDrawableList)) (car theDrawableList) 0)) ) (gimp-file-save RUN-NONINTERACTIVE theImage theDrawable theDestFileName theShortFileName) (gimp-image-delete theImage) ) ; ; ; ; (if (> (+ inApplyWM inApplyRsz) 0) (set! theDrawable (car (gimp-image-get-active-layer theImage))) (gimp-message (number->string theDrawable)) (gimp-image-delete theImage)

) (set! theFileList (cdr theFileList)) ) ) )

(script-fu-register "script-fu-batch-internet-publish" "<Image>/Filters/Batch/Internet Publish" "Resizes images to a max pixel size, \ keeping the current ratio. Automatically\ detects which side as the highest one." "Felipe Carvalho" "copyright 2012, Felipe Carvalho" "June 12, 2012" "" ;image type that the ;inOS SF-OPTION ;inSrcPath SF-DIRNAME ;inMatchFile SF-STRING ;inOverwrite

;func name ;menu label ;description ;author ;copyright notice ;date created script works on

"Operating System (\"\\\" or \"/\"?)" "Source Directory"

'("Windows (\\)" "Linux (/)")

"U:\\Users\\admin\\Pictures" "*.jpg"

"Match Files with (\"*\" to match all)"

SF-TOGGLE "\n\nOverwrite Files in Source Directory?\n=> If enabled, the \"Destination Directory\" parameter is ignored and\n files will be overwritten." 1 ;inDestPath SF-DIRNAME " Destination Directory" "U:\\Users\\admin\\Pictures"

;inApplyWM SF-TOGGLE "\n\nAPPLY WATERMARK? ------------------------------------------------------\n=> Watermark related parameters are ignored if disabled.\n" 1 ;inWmFile SF-FILENAME " WATERMARK IMAGE" "U:\\Users\\admin\\Pictures\\watermark.gbr" ;inXMarginI SF-ADJUSTMENT " Image X margin" '(50 0 250 1 10 0 1) ;inYMarginI SF-ADJUSTMENT " Image Y margin" '(25 0 250 1 10 0 1) ;inOpaI SF-ADJUSTMENT " Image opacity" '(40 1 100 1 10 0 1) ;inWmText SF-STRING " WATERMARK TEXT" "(c)2012 Author Name" ;inXMarginT SF-ADJUSTMENT " Text X margin" '(50 0 250 1 10 0 1) ;inYMarginT SF-ADJUSTMENT " Text Y margin" '(25 0 250 1 10 0 1) ;inOpaT SF-ADJUSTMENT " Text opacity" '(50 1 100 1 10 0 1) ;inOpaTb SF-ADJUSTMENT " Text perimeter opacity" '(0 0 100 1 10 0 1) ;inWmFont SF-FONT " Font" "Segoe Print" ;inWmFontSize SF-ADJUSTMENT " Font Size (pixels)" '(22 6 1000 1 10 0 1) ;inWmFontColor SF-COLOR " Font color" '(255 255 255) ;inWmNoColor ; SF-TOGGLE " No color i.e. lighten or darken image" FALSE SF-OPTION " No color i.e. lighten or darken image" '("No" "Yes") ;inWmEmboss ; SF-TOGGLE " Emboss Text" TRUE SF-OPTION " Emboss Text" '("No" "Yes") ;inTopLef SF-OPTION " TOP-LEFT" '("No Watermark" "Image Watermark" "Text Watermark") ;inTopRig SF-OPTION " TOP-RIGHT" '("No Watermark" "Image Watermark" "Text Watermark")

;inBotLef SF-OPTION ;inBotRig SF-OPTION ;inCentered SF-OPTION

" " "

BOTTOM-LEFT" BOTTOM-RIGHT" CENTER"

'("No Watermark" "Image Watermark" "Text Watermark") '("No Watermark" "Image Watermark" "Text Watermark") '("No Watermark" "Image Watermark" "Text Watermark")

;inApplyRsz SF-TOGGLE "\n\nRESIZE PICTURES? ---------------------------------------------------------\n=> Script automatically detects larger side (width or height) and applies\n the limit to it, keeping original size ratio." 1 ;inMaxSizeType SF-OPTION " Max Size (pixels)" '("1920 (Full_HD)" "1600 (UXGA)" "1280 (720p_HDWXGA)" "1024 (XGA)" " 800 (SVGA)" " 640 (VGA)") )

Vous aimerez peut-être aussi