Bug#169268: gimp script for CD menubar
tags 169268 patch
thanks
[Sorry if this becomes doubled, had problems with the BTS]
Hi.
I tried to get this running. Attached the gimp script from the bug
report (slightly modified to not generate transparent pngs[0]), a new
Makefile for /CD/pictures and a config file (cd-pics.conf) that
should be placed in this directory too.
Last but not least a patch against the cdimage.wml template to use
the generated pictures.
Run make pics to generate the images and make install to use them.
The proposed font is in the t1-xfree86-nonfree package.
[0] I've found this change by the trial-and-error method. I don't know
anything about gimp oder scheme programming...
TODO: Readme file for translators
Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
; __ _
; |_) /| Copyright (C) 2002 Richard Atterer
; | \/¯| <atterer@debian.org>
; ¯ '` ¯
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License, version 2. See
; the file COPYING for details.
; Copy this script to ~/.gimp-1.2/scripts/ before starting the Gimp.
; The script will become available via the menu entry
; "Xtns/Script-Fu/Debian/Debian-CD menubar".
; To create an image from the command line, use:
; gimp -i -c -d -s -b '(script-fu-debian-cd-bar "debian/rules" "-bigelow-luximono-medium-r-normal-*-*-640-*-*-p-*-iso10646-1" 130 32 "rules.png")' '(gimp-quit 0)'
; The "130" is the fontsize (13.0 pt). The luximono font is part of
; the xfonts-scalable-nonfree package (used to be called lucida mono
; in older releases). The output file is always in PNG format. The
; pink background colour is hardwired below as RGB 0xdd9988.
;======================================================================
(define (script-fu-debian-cd-bar text fontname fontsize final-height
filename)
; user variables
;(set! fontsize 130) ; in pt*10
;(set! fontname "-bigelow-luximono-medium-r-normal-*-*-640-*-*-p-*-iso10646-1")
;(set! fontname "-bigelow-luximono-medium-r-normal-*-*-640-*-*-p-*-iso8859-1")
;(set! fontname "-zz abiword-luxi mono (iso 8859 1)-medium-r-normal-*-*-640-*-*-p-*-iso8859-1")
(set! background-colour '(221 153 136)) ; RGB 0xdd9988
;(set! final-height 32) ; height of output image
;______________________________________________________________________
(set! border 10) ; To leave room for blurring/bumpmapping
(set! blur-radius 5) ; For Gauß RLE blur
; Create canvas
(set! image (car (gimp-image-new final-height final-height RGB)))
; How high/wide in pixels is the text going to be?
(set! text-extents (gimp-text-get-extents-fontname text fontsize
POINTS fontname))
(set! text-width (car text-extents))
(set! text-height (cadr text-extents))
(set! text-ascent (caddr text-extents))
(set! text-descent (caddr (cdr text-extents)))
;______________________________________________________________________
; Create white-on-black text layer
(set! image-width (+ text-width (* 2 border)))
(set! image-height (+ text-height (* 2 border)))
(if (< image-height final-height)
(set! image-height final-height))
(set! text-bw (car (gimp-layer-new image text-width text-height
RGB_IMAGE "text-bw" 100 NORMAL)))
(gimp-image-add-layer image text-bw -1) ; at top of layer stack
(gimp-layer-set-visible text-bw FALSE)
(gimp-palette-set-background '(0 0 0))
(gimp-palette-set-foreground '(255 255 255))
(gimp-edit-fill text-bw 1) ; Fill with bg col
; Create text and anchor it to text-bw
(print " painting text - in case of error, check whether font is available")
(gimp-floating-sel-anchor
(car (gimp-text-fontname image text-bw 0 0 text -1 TRUE
fontsize POINTS fontname)))
(print " done")
; resize, adding black border around the white-on-black text
(gimp-layer-resize text-bw image-width image-height border
(/ (- image-height text-height) 2) )
(gimp-layer-set-offsets text-bw 0 0)
(gimp-image-resize image image-width image-height 0 0)
;______________________________________________________________________
; Make copy of text-bw layer in text-blur, blur that for use as bumpmap
(set! text-blur (car (gimp-layer-copy text-bw FALSE))) ; no alpha chan
(gimp-layer-set-name text-blur "text-blur")
(gimp-image-add-layer image text-blur -1) ; at top of layer stack
(gimp-layer-set-visible text-blur FALSE)
(plug-in-gauss-rle TRUE image text-blur blur-radius TRUE TRUE)
;______________________________________________________________________
; Create background layer
(gimp-palette-set-background background-colour)
(set! background (car (gimp-layer-new image image-width image-height
RGB_IMAGE "background" 100 NORMAL)))
(gimp-image-add-layer image background 9) ; at bottom of layer stack
(gimp-edit-fill background 1) ; Fill with bg col
(gimp-layer-set-visible background TRUE)
; Now bumpmap it with text-blur
(plug-in-bump-map TRUE image background text-blur
125 20 1 ; azimuth, elevation, depth
0 0 0 60 ; X/Y offset, waterlevel, ambient
TRUE TRUE 0) ; compensate, invert map, linear map
;______________________________________________________________________
; Create another completely black layer for the final text
(set! text (car (gimp-layer-new image image-width image-height
RGB_IMAGE "text" 100 NORMAL)))
(gimp-image-add-layer image text -1) ; at top of layer stack
(gimp-layer-set-visible text TRUE)
(gimp-palette-set-background '(0 0 0))
(gimp-edit-fill text 1) ; Fill with bg col
; Add an alpha mask to that layer
(gimp-layer-add-alpha text)
(set! text-mask (car (gimp-layer-create-mask text 1)))
(gimp-image-add-layer-mask image text text-mask)
; Copy text-bw to alpha mask
(gimp-edit-copy text-bw)
(gimp-floating-sel-anchor (car (gimp-edit-paste text-mask 0)))
;======================================================================
; Image is finished!
; Remove temporary layers
(gimp-image-remove-layer image text-bw)
(gimp-image-remove-layer image text-blur)
; Merge remaining layers
(gimp-image-merge-visible-layers image 1) ; CLIP_TO_IMAGE
; Convert to indexed
(gimp-convert-indexed image 0 0 ; dither=none, MAKE_PALETTE
31 FALSE TRUE "")
; Select those parts that have the background colour, make them
; transparent.
(set! background (aref (cadr (gimp-image-get-layers image)) 0))
(gimp-fuzzy-select background 0 0 0 ; x/y, threshold
2 FALSE 0 0 FALSE) ; REPLACE, antialias, feath/rad, merg
;(gimp-edit-clear background)
(gimp-selection-none image)
; Remove some of the border
(set! final-width (+ text-width (* 2 blur-radius)))
(gimp-crop image (- final-width 2) (- final-height 2)
(/ (- image-width final-width -2) 2)
(/ (- image-height final-height -2) 2))
(gimp-palette-set-background background-colour)
;______________________________________________________________________
(if (= (string-length filename) 0)
(gimp-display-new image)
(file-png-save TRUE image background filename filename
FALSE 9 TRUE ; interlace, compression, background col
FALSE FALSE FALSE FALSE)) ; gamma, off, time, phys
)
;======================================================================
(script-fu-register
"script-fu-debian-cd-bar" ; function name
"<Toolbox>/Xtns/Script-Fu/Debian/Debian-CD menubar" ; menu position
"PNG generator for http://www.debian.org/CD/"
"Richard Atterer <atterer@debian.org>" ; author
"Copyright 2002 - released under the GPL" ; copyright message
"Jul 13, 2002" ; date created
"" ; Image type that the script works on
SF-VALUE "Text" "\"net_install\"" ; a text variable
SF-FONT "Font" "-b&h-luxi_mono-medium-r-normal-*-*-640-*-*-m-*-iso8859-1"
SF-VALUE "Font size (pt*10)" "130"
SF-VALUE "Final height (pixels)" "32"
SF-VALUE "Filename or \"\" to display" "\"\""
)
# This Makefile should need no changes from webwml/english/CD/pictures/Makefile
# Please send a message to debian-www if you need to modify anything
# so the problem can be fixed.
WMLBASE=../..
CUR_DIR=CD/pictures
SUBS=
include $(WMLBASE)/Make.lang
CONFFILE = cd-pics.conf
include $(CONFFILE)
GIMP = gimp
GIMPRC = $(CURDIR)/$(ENGLISHDIR)/$(CUR_DIR)/gimprc
SCRIPT = $(ENGLISHDIR)/$(CUR_DIR)/debian-cd-bar.scm
SCRIPT_DEPS = $(GIMPRC) $(SCRIPT) $(CONFFILE)
FONTFACE ?= b&h-luxi_mono
FONTSIZE ?= 130
FONTTYPE ?= medium
FONTREGISTRY ?= iso8859
FONTENCODING ?= 1
PIC_SCRIPT = $(GIMP) --gimprc $(GIMPRC) -i -c -d -s -b '(script-fu-debian-cd-bar "$(1)" "-$(FONTFACE)-$(FONTTYPE)-r-normal-*-*-640-*-*-m-*-$(FONTREGISTRY)-$(FONTENCODING)" $(FONTSIZE) 32 "$(2)")' '(gimp-quit 0)'
$(GIMPRC):
echo '(script-fu-path "$(CURDIR)/$(ENGLISHDIR)/$(CUR_DIR)")' > $@
menu-buy.$(LANGUAGE).png: $(SCRIPT_DEPS)
$(call PIC_SCRIPT,$(BUY_TEXT),$@)
menu-faq.$(LANGUAGE).png: $(SCRIPT_DEPS)
$(call PIC_SCRIPT,$(FAQ_TEXT),$@)
menu-http-ftp.$(LANGUAGE).png: $(SCRIPT_DEPS)
$(call PIC_SCRIPT,$(HTTP_FTP_TEXT),$@)
menu-jigdo.$(LANGUAGE).png: $(SCRIPT_DEPS)
$(call PIC_SCRIPT,$(JIGDO_TEXT),$@)
menu-misc.$(LANGUAGE).png: $(SCRIPT_DEPS)
$(call PIC_SCRIPT,$(MISC_TEXT),$@)
menu-netinst.$(LANGUAGE).png: $(SCRIPT_DEPS)
$(call PIC_SCRIPT,$(NET_INST_TEXT),$@)
pics: menu-buy.$(LANGUAGE).png menu-http-ftp.$(LANGUAGE).png \
menu-misc.$(LANGUAGE).png menu-faq.$(LANGUAGE).png \
menu-jigdo.$(LANGUAGE).png menu-netinst.$(LANGUAGE).png
# Button text for your language
FAQ_TEXT := faq
NET_INST_TEXT := net_install
BUY_TEXT := buy
JIGDO_TEXT := jigdo
HTTP_FTP_TEXT := http_ftp
MISC_TEXT := misc
# Font settings. The defaults are:
#
# FONTFACE := b&h-luxi_mono
# FONTSIZE := 130
# FONTTYPE := medium
# FONTREGISTRY := iso8859
# FONTENCODING := 1
Index: cdimage.wml
===================================================================
RCS file: /cvs/webwml/webwml/english/template/debian/cdimage.wml,v
retrieving revision 1.51
diff -u -r1.51 cdimage.wml
--- cdimage.wml 28 Jan 2003 13:55:31 -0000 1.51
+++ cdimage.wml 29 Sep 2003 19:41:33 -0000
@@ -71,14 +71,14 @@
# will be changed to $(CUR_ISO_LANG) once it's possible
# for now, use the English pictures
-<define-tag cdpiclang>en</define-tag>
+<define-tag cdpiclang>$(CUR_ISO_LANG)</define-tag>
#use wml::debian::header LINK="#8c4939" VLINK="#45241c" ALINK="#ff2600"
<table width="100%" bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="middle">
- <a href="$(HOME)/CD/"><img src="$(HOME)/CD/pictures/cdimage.<cdpiclang>.png" alt="<debiancd>" width="380" height="82" border="0"></a>
+ <a href="$(HOME)/CD/"><img src="$(HOME)/CD/pictures/cdimage.en.png" alt="<debiancd>" width="380" height="82" border="0"></a>
</td>
<td align="right" valign="middle">
<a href="$(HOME)/"><img src="$(HOME)/logos/openlogo-nd-50.png" border="0" hspace="0" vspace="0" alt="" /></a>
@@ -93,12 +93,12 @@
<img src="$(HOME)/CD/pictures/menubar-tl.png" width="16" height="16" alt="" align="left" border="0" hspace="0" vspace="0">
</td>
<td rowspan="2" align="center" valign="middle">
- <a href="$(HOME)/CD/faq/"><img src="$(HOME)/CD/pictures/menu-faq.<cdpiclang>.png" width="40" height="27" alt="<dc_faq> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
- <a href="$(HOME)/CD/netinst/"><img src="$(HOME)/CD/pictures/menu-netinst.<cdpiclang>.png" width="125" height="27" alt="<dc_net> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
- <a href="$(HOME)/CD/vendors/"><img src="$(HOME)/CD/pictures/menu-buy.<cdpiclang>.png" width="41" height="27" alt="<dc_buy> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
- <a href="$(HOME)/CD/jigdo-cd/"><img src="$(HOME)/CD/pictures/menu-jigdo.<cdpiclang>.png" width="60" height="27" alt="<dc_jigdo> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
- <a href="$(HOME)/CD/http-ftp/"><img src="$(HOME)/CD/pictures/menu-http-ftp.<cdpiclang>.png" width="93" height="27" alt="<dc_httpftp> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
- <a href="$(HOME)/CD/misc"><img src="$(HOME)/CD/pictures/menu-misc.<cdpiclang>.png" width="50" height="27" alt="<dc_misc>" border="0" align="middle" hspace="6" vspace="1"></a>
+ <a href="$(HOME)/CD/faq/"><img src="$(HOME)/CD/pictures/menu-faq.<cdpiclang>.png" alt="<dc_faq> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
+ <a href="$(HOME)/CD/netinst/"><img src="$(HOME)/CD/pictures/menu-netinst.<cdpiclang>.png" alt="<dc_net> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
+ <a href="$(HOME)/CD/vendors/"><img src="$(HOME)/CD/pictures/menu-buy.<cdpiclang>.png" alt="<dc_buy> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
+ <a href="$(HOME)/CD/jigdo-cd/"><img src="$(HOME)/CD/pictures/menu-jigdo.<cdpiclang>.png" alt="<dc_jigdo> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
+ <a href="$(HOME)/CD/http-ftp/"><img src="$(HOME)/CD/pictures/menu-http-ftp.<cdpiclang>.png" alt="<dc_httpftp> <sep>" border="0" align="middle" hspace="6" vspace="1"></a>
+ <a href="$(HOME)/CD/misc"><img src="$(HOME)/CD/pictures/menu-misc.<cdpiclang>.png" alt="<dc_misc>" border="0" align="middle" hspace="6" vspace="1"></a>
</td>
<td align="right" valign="top">
<img src="$(HOME)/CD/pictures/menubar-tr.png" width="16" height="16" alt="" align="right" border="0" hspace="0" vspace="0">
Reply to: