| 125 | |
| 126 | |
| 127 | def write_images(info, dir_path, installer_type="exe"): |
| 128 | if installer_type == "exe": |
| 129 | instructions = [ |
| 130 | ("welcome", welcome_size, mk_welcome_image, ".bmp"), |
| 131 | ("header", header_size, mk_header_image, ".bmp"), |
| 132 | ("icon", icon_size, mk_icon_image, ".ico"), |
| 133 | ] |
| 134 | elif installer_type == "pkg": |
| 135 | instructions = [ |
| 136 | ("welcome", welcome_size_osx, mk_welcome_image_osx, ".png"), |
| 137 | ] |
| 138 | elif installer_type == "msi": |
| 139 | # MSI uses WiX defaults; user-provided images handled separately below |
| 140 | instructions = [] |
| 141 | else: |
| 142 | raise ValueError( |
| 143 | f"Installer type '{installer_type}' not supported. Choose 'exe', 'pkg', or 'msi'." |
| 144 | ) |
| 145 | |
| 146 | for name, size, function, ext in instructions: |
| 147 | key = name + "_image" |
| 148 | if info.get(key): |
| 149 | im = Image.open(info[key]) |
| 150 | im = im.resize(size) |
| 151 | else: |
| 152 | add_color_info(info) |
| 153 | im = function(info) |
| 154 | assert im.size == size |
| 155 | im.save(join(dir_path, name + ext)) |
| 156 | |
| 157 | # MSI: handle custom images if provided (no auto-generation) |
| 158 | if installer_type == "msi": |
| 159 | if info.get("welcome_image"): |
| 160 | im = _resize_for_msi_welcome(info["welcome_image"]) |
| 161 | assert im.size == welcome_size_msi |
| 162 | im.save(join(dir_path, "welcome.bmp")) |
| 163 | if info.get("header_image"): |
| 164 | im = Image.open(info["header_image"]) |
| 165 | im = im.resize(header_size_msi) |
| 166 | im.save(join(dir_path, "header.bmp")) |
| 167 | if info.get("icon_image"): |
| 168 | im = Image.open(info["icon_image"]) |
| 169 | im = im.resize(icon_size) |
| 170 | im.save(join(dir_path, "icon.ico")) |