About Image Format Converter

The Image Format Converter (krkrtpc.exe in the tools folder) is a tool for converting Kirikiri images between various formats.
It can be used to prepare various images.

Input file formats include BMP, PNG, JPEG, and PSD. Output file formats include BMP, PNG, TLG5, TLG6, and JPEG.
It can also read and output transparent images in the main/mask separated format used by Kirikiri. The term "mask" used here is synonymous with alpha channel.

Since it basically just converts image formats, images output by this tool can likely be used with other software and tools.

Note that this is not limited to this tool, but don't forget to make backups!

Input Image Formats

The following formats can be used as input file formats.

BMP
Windows standard bitmap format. 32-bit (bpp) BMPs are treated as BMPs with an alpha channel.
Other BMP formats are treated as opaque images (images without transparency information), except when used in the main/mask separated format described later.
PNG
Portable Network Graphic format. PNGs with transparency (alpha channel or transparency information) can also be read.
PSD
Adobe Photoshop 3 or later format. However, there are significant limitations for PSDs readable by this tool:

  • Cannot read color modes other than RGB
  • Cannot read 16-bit/channel images
  • Supports only uncompressed and RLE compression (Photoshop 3.0 format supports RLE only)

This format cannot be read as a main/mask separated format. Most data can be read, but some cannot.
If using a color mode other than RGB (such as CMYK), please convert it to RGB. If using 16-bit/channel, please convert it to 8-bit/channel.
If it contains layers with blend modes other than "Normal", it should be fine if you "Merge Visible" before inputting into this tool.

PSD reading functionality changes significantly depending on whether "Output in ltAddAlpha format" is selected.

If "Output in ltAddAlpha format" is NOT selected: Can read PSD files containing "Normal", "Linear Dodge", "Linear Burn", "Multiply", "Screen", "Overlay", "Hard Light", "Soft Light", "Color Dodge", "Color Burn", "Lighten", "Darken", "Difference", and "Exclusion" layers. Also, if the image consists only of "Normal" layers, multiple overlapping layers are supported (other modes do not support multiple overlapping layers).

If "Output in ltAddAlpha format" IS selected: Only "Normal" and "Linear Dodge" layers are supported. In this case, layers must be ordered from bottom (back) to top as: "any number of 'Normal' layers" followed by "any number of 'Linear Dodge' layers". "Any number" means 0 (no layers) or 1 or more layers.
Examples of readable configurations when "Output in ltAddAlpha format" is selected
  • One "Linear Dodge" layer on top of one "Normal" layer
  • Only one "Linear Dodge" layer with no "Normal" layer
  • Only one "Normal" layer
  • Two "Linear Dodge" layers on top of three "Normal" layers
Examples of unreadable configurations when "Output in ltAddAlpha format" is selected
  • One "Normal" layer on top of one "Linear Dodge" layer on top of one "Normal" layer
    (Linear Dodge layers cannot be sandwiched between Normal layers)
  • One "Linear Dodge" layer on top of one "Normal" layer on top of one "Linear Dodge" layer
    (Normal layers cannot be sandwiched between Linear Dodge layers)
  • Only one "Dodge" layer
    (Only "Linear Dodge" is supported, not standard "Dodge")
Photoshop's "Normal" corresponds to Kirikiri's alpha blending, and "Linear Dodge" corresponds to Kirikiri's additive blending. Since ltAdditiveAlpha (additive alpha blending) can represent both alpha blending and additive blending simultaneously, Photoshop data with this layer configuration can be read.

JPEG
Standard full-color and grayscale JPEG formats can be read. Can also be used as input for the main/mask separated format described later.
Main/Mask Separated Format
A format where the main (color information) image and the mask (transparency information) image are in separate files.
The mask image file name is the main image file name with _m appended (e.g., test_m.jpg for test.jpg).
Valid input formats for main/mask separation are BMP, JPEG, and PNG. The main and mask formats do not need to match.

Note
TLG5 and TLG6 formats cannot be used as input. ERI format is currently not supported.

Output Image Formats

The following formats can be used as output image formats.

24bit/32bit BMP
24-bit BMP is a BMP without an alpha channel.
32-bit BMP is a BMP with an alpha channel, containing both main and mask within a single file.
PNG
Full-color PNG or PNG with an alpha channel.
TLG5
Full-color TLG5 or TLG5 with an alpha channel.

Note
TLG5 compression takes a considerable amount of time. The program may appear to have stopped.

TLG6
Full-color TLG6 or TLG6 with an alpha channel.

Note
Like TLG5, TLG6 compression takes a considerable amount of time. The program may appear to have stopped.

Tag information is written for TLG6 images, just like TLG5.
Main/Mask Separated Format
A method to record the main/mask in separate files for images with transparency. BMP, JPEG, or PNG can be selected for each.
The mask image file name is the main image file name with _m appended (e.g., test_m.jpg for test.jpg).
While main and mask can be different formats, combinations like BMP/BMP or PNG/PNG make little sense; it's better to choose 32-bit BMP or PNG with alpha channel.
Using JPEG for one or both saves file size but reduces image quality.
TLG5 and TLG6 cannot be specified for main/mask separated format.

Tag Information

The Image Format Converter writes "tag information" to TLG and PNG images. "Tag information" includes data such as how the image should be displayed. This tag information can be obtained as the return value of the Layer.loadImages method.

The following tag information is written.
mode (TLG only)
The display mode of the image. For "opaque images", mode=opaque is written. If the output format is ltAddAlpha, mode=addalpha is written.
For "images with transparency", if the output format is not ltAddAlpha: if the input was not a PSD or was a PSD with only "Normal" layers, it becomes mode=alpha. For PSD files with layers other than "Normal", information corresponding to each blend mode is written.
In KAG, this corresponds directly to the mode attribute of the image tag and serves as the default value when the mode attribute is omitted. This means that in KAG, the appropriate mode attribute is set automatically even if not specified.

Kirikiri has a dictionary array called imageTagLayerType in the TJS global object, which defines how the mode in the TLG tag information maps to layer types:

global.imageTagLayerType = %[
    opaque      :%[type:ltOpaque            ],
    rect        :%[type:ltOpaque            ],
    alpha       :%[type:ltAlpha             ],
    transparent :%[type:ltAlpha             ],
    addalpha    :%[type:ltAddAlpha          ],
    add         :%[type:ltAdditive          ],
    sub         :%[type:ltSubtractive       ],
    mul         :%[type:ltMultiplicative    ],
    dodge       :%[type:ltDodge             ],
    darken      :%[type:ltDarken            ],
    lighten     :%[type:ltLighten           ],
    screen      :%[type:ltScreen            ],
    psnormal    :%[type:ltPsNormal          ],
    psadd       :%[type:ltPsAdditive        ],
    pssub       :%[type:ltPsSubtractive     ],
    psmul       :%[type:ltPsMultiplicative  ],
    psscreen    :%[type:ltPsScreen          ],
    psoverlay   :%[type:ltPsOverlay         ],
    pshlight    :%[type:ltPsHardLight       ],
    psslight    :%[type:ltPsSoftLight       ],
    psdodge     :%[type:ltPsColorDodge      ],
    psdodge5    :%[type:ltPsColorDodge5     ],
    psburn      :%[type:ltPsColorBurn       ],
    pslighten   :%[type:ltPsLighten         ],
    psdarken    :%[type:ltPsDarken          ],
    psdiff      :%[type:ltPsDifference      ],
    psdiff5     :%[type:ltPsDifference5     ],
    psexcl      :%[type:ltPsExclusion       ],
]

Refer to the Graphic System for details on each layer type.
offs_x offs_y offs_unit (TLG, PNG)
These are output only if the source is a PNG and that PNG contains offset information (oFFs chunk) from the top-left corner.
offs_x is the distance from the left edge, and offs_y is the distance from the top edge. offs_unit is either pixel or micrometer, indicating the unit of distance.
vpag_w vpag_h vpag_unit (TLG, PNG)
These are output only if the source is a PNG and that PNG contains Virtual PAGe information (vpAg chunk), i.e., the size of the entire image.
ImageMagick is a software that outputs this information to PNG; when trimming with ImageMagick, this information is output as the image size before trimming.
vpag_w is the width of the entire image, vpag_h is the height, and offs_unit is either pixel or micrometer, indicating the unit of size.
reso_x reso_y reso_unit (TLG, PNG)
These are output only if the source is a PNG and that PNG contains resolution information (pHYs chunk).
reso_x is the horizontal resolution, reso_y is the vertical resolution. reso_unit is meter, indicating the unit of resolution.

How to Use the Image Format Converter


Conversion can be performed by dropping the files you want to convert onto the Image Format Converter window. Multiple files can be dropped at once.

Different formats can be specified for opaque images and images with transparency.

An "opaque image" refers to an image that is completely opaque across its entire area (e.g., background images used in KAG). An "image with transparency" refers to an image that has transparent parts (e.g., foreground images used in KAG).
Note that even if an image format supports transparency, if all pixels are actually fully opaque, it will be treated as an "opaque image".

After conversion, a log will be displayed where you can check if the conversion of each file was successful or resulted in an error.

Below is a description of the screen.

TPC.png

When executed, the screen above is displayed.

"Show Options"
When checked, the settings section below is displayed. When unchecked, the window shows only the top part and becomes narrow. You can compact the window when option settings are not needed.
"Opaque Image - 24bit BMP"
Selects 24-bit BMP as the output format for opaque images.
"Opaque Image - PNG"
Selects PNG as the output format for opaque images.
"Opaque Image - TLG5"
Selects TLG5 as the output format for opaque images.
"Opaque Image - TLG6"
Selects TLG6 as the output format for opaque images.
"Opaque Image - JPEG"
Selects JPEG as the output format for opaque images.
"Opaque Image - JPEG Options..."
Selects the JPEG compression quality when JPEG is chosen as the output format for opaque images.
"Image with Transparency - 32bit BMP (Main+Mask)"
Selects 32-bit BMP as the output format for images with transparency.
"Image with Transparency - PNG with Alpha (Main+Mask)"
Selects PNG with alpha channel as the output format for images with transparency.
"Image with Transparency - TLG5 with Alpha (Main+Mask)"
Selects TLG5 with alpha channel as the output format for images with transparency.
"Image with Transparency - TLG6 with Alpha (Main+Mask)"
Selects TLG6 with alpha channel as the output format for images with transparency.
"Image with Transparency - Main/Mask Separated Format"
Specifies main/mask separated format as the output format for images with transparency. Select what to use for main/mask below. For JPEG, you can select the compression quality by clicking the "JPEG Options" button.
"Image with Transparency - Treat input image as ltAddAlpha format"
If checked, the input image is treated as being in ltAddAlpha format (additive alpha blending), suitable for display by specifying ltAddAlpha in Kirikiri's Layer.type property. This option affects BMP, PNG, and main/mask separated formats; PSD format is not affected.
If unchecked, the input image is treated as ltAlpha format. Since most graphic software output and PNG specifications are in ltAlpha format, this option should normally be unchecked.
If this is unchecked and "Output in ltAddAlpha format" (described below) is checked, the converter will convert from ltAlpha to ltAddAlpha.
If checked, "Output in ltAddAlpha format" is automatically checked, and "Color information for fully transparent areas" becomes unavailable (alpha and color info will not be processed by the converter).
"Image with Transparency - Output in ltAddAlpha format"
If checked, the output image is saved in ltAddAlpha format.
If unchecked, the output format will be ltAlpha, or for PSD input, the format corresponding to the blend mode of the layers in that file.
Since many graphic tools and the PNG spec only accept ltAlpha, normally leave this unchecked unless using the output specifically for Kirikiri.
If checked, "Color information for fully transparent areas" becomes unavailable (alpha and color info will not be processed by the converter).
"Image with Transparency - Color information for fully transparent areas"
Specifies how to handle completely transparent parts of the image.
Normally, in ltAlpha format, even fully transparent parts have color information. These parts are ignored during display but not during processing (like JPEG compression).
Specifies the processing method for these fully transparent areas.

Remove
Color information in fully transparent areas is removed (specifically, filled with black).
Usually, this is fine.
As Is
No processing. The original image is kept as is.
If there is noise in fully transparent areas, it will be compressed, reducing the compression ratio.
Synthesize
Estimates and synthesizes the color of fully transparent areas from the surrounding opaque colors.
Synthesis strength can be chosen from 1, 2, 3, 5, or 8 pixels. Colors are synthesized from opaque pixels within the specified distance. Larger values take more time. Colors outside this distance are removed.
For example, when compressing the main image with JPEG, mosquito noise occurs at sharp color transitions. In foreground images, if "Synthesize" is not used and there's a sharp change at the boundary, noise is likely. "Synthesize" reduces this difference and suppresses noise. It also prevents unintended mixing of transparent and opaque colors in standard JPEG.
Normally, choose "Remove". Color information is not needed in fully transparent areas, and removing it reduces the file size after compression.
If "Output in ltAddAlpha format" is checked, this option becomes unavailable. In ltAddAlpha format, "fully transparent" can only mean opacity 0 and color black.
"Output Folder - Same folder as input file"
Outputs files to the same folder as the input.
"Output Folder - Specified folder"
Outputs files to the folder specified in the input field.
Click "Browse..." to open a dialog to select the output folder.
Relative paths are relative to the input file's folder.
"Output Folder - Overwrite if file with same name exists"
If checked, overwrites existing files.
"Do not show log if no errors occurred"
If checked, the log window won't appear if conversion finishes without errors.
"Close"
Exits the tool.