build: generate the Windows installer welcome images from the splash screen.

After discussion with Jernej, InnoSetup should now work better with rescaling
a big image properly to the window size, yet the ratio should still matter.
Apparently the welcome image is a hack and this is why it requires specific
ratio images. We don't use the big size yet, but since Jernej told me which
dimensions are expected, I already added the code for it to make it easier
later.

So anyway this code would allow us not to have to commit welcome images each
time, which are basically resized copy in BMP of the splash screen, slowly yet
surely filling up our repository with image duplicates.
After all, we develop a scriptable image editor! We should use it to edit images
and export in expected formats!

I only use this script for the devel installer for now, for testing and see how
it goes.
This commit is contained in:
Jehan 2023-06-27 00:25:27 +02:00
parent 8676907c6d
commit 2fd25fe6bd
7 changed files with 61 additions and 8 deletions

View file

@ -414,7 +414,7 @@ gimp-win64-native:
expire_in: 1 day
paths:
- _install-w64
- _build-w64/build/windows/installer/lang/
- _build-w64/build/windows/installer/
- _build-w64/meson-*/
cache:
paths:
@ -446,7 +446,7 @@ packaging-win64-native:
expire_in: 1 day
paths:
- gimp-w64
- _build-w64/build/windows/installer/lang/
- _build-w64/build/windows/installer/
- done-dll.list
needs: ["gimp-win64-native"]

View file

@ -74,6 +74,9 @@ cd -
# Copy generated language files into the source directory.
cp _build-w64/build/windows/installer/lang/*isl build/windows/installer/lang
# Copy generated welcome images into the source directory.
cp _build-w64/build/windows/installer/*bmp build/windows/installer/
# Construct now the installer.
VERSION=`grep -rI '\<version *:' meson.build | head -1 | sed "s/^.*version *: *'\([0-9]\+\.[0-9]\+\.[0-9]\+\)' *,.*$/\1/"`
#MAJOR_VERSION=`echo $VERSION | sed "s/^\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)$/\1/"`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 KiB

View file

@ -1 +1,13 @@
subdir('lang')
source_splash=meson.project_source_root() + '/data/images/gimp-splash.png'
installsplash = custom_target('installsplash-devel.bmp',
input : [ 'splash2installer.py' ],
depend_files: [ source_splash ],
output: [ 'installsplash-devel.bmp', ],
command: [ gimpmain_exe, '-nidfs', source_splash,
'--batch-interpreter', 'python-fu-eval',
'-b', '-', '--quit'],
feed: true,
build_by_default: true
)

View file

@ -0,0 +1,38 @@
image = Gimp.list_images()[0]
config = Gimp.get_pdb().lookup_procedure("file-bmp-save").create_config()
def export_scaled_img(image, target_width, target_height, export_path):
img = image.duplicate()
w = img.get_width()
h = img.get_height()
new_width = target_width
new_height = target_height
offx = 0
offy = 0
if w / target_width * target_height < h:
new_width = target_height / h * w
offx = (target_width - new_width) / 2
else:
new_height = target_width / w * h
offy = (target_height - new_height) / 2
img.scale(new_width, new_height)
img.resize(target_width, target_height, offx, offy)
# XXX: should we rather use the average color as border?
black = Gimp.RGB()
black.set(0, 0, 0)
Gimp.context_set_background(black)
drawables = img.list_selected_drawables()
for d in drawables:
d.resize_to_image_size()
config.set_property("image", img)
config.set_property("num-drawables", len(drawables))
config.set_property("drawables", Gimp.ObjectArray.new(Gimp.Drawable, drawables, False))
config.set_property("file", Gio.file_new_for_path(export_path))
Gimp.get_pdb().run_procedure_config("file-bmp-save", config)
# These sizes are pretty much hardcoded, and in particular the ratio matters in
# InnoSetup. Or so am I told. XXX
export_scaled_img(image, 994, 692, 'build/windows/installer/installsplash-devel.bmp')
export_scaled_img(image, 497, 360, 'build/windows/installer/installsplash_small-devel.bmp')
export_scaled_img(image, 1160, 803, 'build/windows/installer/installsplash_big-devel.bmp')

View file

@ -1804,12 +1804,6 @@ meson.add_dist_script('meson_dist_script.sh',
rootInclude = include_directories('.')
appInclude = include_directories('app')
subdir('build/windows')
if get_option('windows-installer')
subdir('po-windows-installer')
subdir('build/windows/installer')
endif
# Tools
subdir('libgimpbase')
subdir('tools')
@ -1852,6 +1846,12 @@ subdir('app-tools')
subdir('docs')
subdir('devel-docs')
# Windows installer
subdir('build/windows')
if get_option('windows-installer')
subdir('po-windows-installer')
subdir('build/windows/installer')
endif
pkgconfig.generate(libgimp,
filebase: 'gimp-' + gimp_api_version,