; SPDX-FileCopyrightText: 2024 Edward Ly ; ; SPDX-License-Identifier: GPL-3.0-or-later (script-fu-register "script-fu-sm-jacket-to-bg" "SM Jacket to Background" "Convert a song jacket to a generic background image for use in StepMania/Project OutFox." "Edward Ly " "Edward Ly" "2024" "*" SF-IMAGE "Current Image" -1 SF-DRAWABLE "Current Drawable" -1 SF-ADJUSTMENT "Blur Radius" '(25 0 100 1 10 2 0) SF-ADJUSTMENT "Brightness" '(-1.0 -1.0 1.0 0.01 0.1 2 0) ) (script-fu-menu-register "script-fu-sm-jacket-to-bg" "/Image") (define (script-fu-sm-jacket-to-bg currentImg currentDrawable blurRadius brightness) (let* ( ; local variables (jacketSize 512) (bgWidth 1280) (bgHeight 720) ; calculated values (currentImgWidth (car (gimp-drawable-width currentDrawable))) (currentImgHeight (car (gimp-drawable-height currentDrawable))) (centerWidthOffset (/ (- bgWidth currentImgWidth) 2)) (centerHeightOffset (/ (- bgHeight currentImgHeight) 2)) ; layer variables (bgLayer (car (gimp-image-get-active-layer currentImg))) (jacketLayer) ) (gimp-image-undo-group-start currentImg) (gimp-context-set-interpolation INTERPOLATION-LINEAR) (set! jacketLayer (car (gimp-layer-new-from-drawable currentDrawable currentImg))) (gimp-image-insert-layer currentImg jacketLayer 0 0) (gimp-image-resize currentImg bgWidth bgHeight centerWidthOffset centerHeightOffset) (gimp-layer-scale bgLayer bgWidth bgWidth 1) (gimp-layer-scale jacketLayer jacketSize jacketSize 1) (plug-in-gauss RUN-NONINTERACTIVE currentImg currentDrawable blurRadius blurRadius 0) (gimp-drawable-brightness-contrast currentDrawable brightness 0) (gimp-image-merge-visible-layers currentImg CLIP-TO-IMAGE) (gimp-displays-flush) (gimp-image-undo-group-end currentImg) (list currentImg (car (gimp-image-get-active-layer currentImg))) ) )