About Image Format Converter

 The image format converter (krkrtpc.exe in the tools folder) is a tool for cross-conversion of Kirikiri's images.
 It can be used to prepare various images.

 You can select BMP, PNG, JPEG, PSD as the input file format and BMP, PNG, TLG5, TLG6, JPEG as the output file format.
 It can also read and output transparent images in the main / mask separation format used by Kirikiri. The term "mask" used here is synonymous with alpha channel.

 Basically, it only converts the image format, so I think the image output with this can be used for other software and tools.

 It's not limited to this tool, but don't forget to backup!

Input image format

 The following formats can be used as the input file format.

BMP
 Windows standard bitmap format. BMP in 32 bit (bpp) format is considered to be a BMP with an alpha channel.
 Other forms of BMP are considered to be opaque images (images without transparency information) (unless used in the main / mask separation format described below).
PNG
 Portable Network Graphic format. PNGs with transparency (with alpha channel and transparency information) can also be read.
PSD
 This format is used by Adobe Photoshop 3 or later. However, PSDs that can be read by this tool have the following major limitations.

  • Cannot read color modes other than RGB
  • Cannot read 16bit / channel
  • Only uncompressed and RLE compression supported (For Photoshop3.0 format only RLE compression supported)

 This format cannot be read as the main / mask separation format.
 Most data can be read, but some data cannot.
 If you are using a color mode other than RGB (such as CMYK), convert it to RGB. If you are using 16bit / channel, convert to 8bit / channel.
 If you include layers in blend modes other than "Normal", it is okay to perform "Merge Display" before entering this tool.

 The function of reading PSD files changes greatly depending on whether "Export in ltAddAlpha format" is selected or not in the output format.

 When "Output in ltAddAlpha format" is selected, "Normal", "Covering (linear)", "Burning (linear)", "Multiplication", "Screen", "Overlay", "Hard Light", "Soft Light", "Cover edcolor", "Burn Color" You can import PSD files that contain layers of "Comparison (Light)", "Compare (Dark)", "Absolute Value of Difference" and "Exclude". In addition, if the image consists only of "Normal", it can correspond even if multiple layers overlap (in other modes, multiple layers overlap cannot be supported).

 If Output in ltAddAlpha format is selected, only normal and wrap(linear) layers can be used. In this case, the layers must be in the order of "any number of "normal" layers, and "any number of "linear layers", in order from the bottom (from the back). "Any number" is 0 sheets, that is, no layers, or one or more layers.
Example that can be read when "Output in ltAddAlpha format" is selected
  • One "Dodge (Linear)" layer on one "Normal" layer
  • No "normal" layer, only one "dodging (linear)" layer
  • Only one "Normal" layer
  • 2 "Dodge (linear)" layers on 3 "Normal" layers
Example that cannot be read when "Output in ltAddAlpha format" is selected
  • One "Dodge (Linear)" layer on one "Normal" layer, and one more "Normal" layer on it
    (The dodging linear layer cannot be sandwiched between normal layers.)
  • One "normal" layer on one "dodging (linear)" layer, and one "dodging (linear)" layer on it
    (Normal layers cannot be sandwiched between dodging linear layers.)
  • Only one "Dodge" layer
    (Even if you are dodging, you can only handle dodging linear layers)
"Normal" in Photoshop is equivalent to Kirikiri's alpha synthesis, and "Dodge (linear)" is equivalent to Kirikiri's additive synthesis. Since ltAdditiveAlpha (additive alpha compositing) can express both alpha compositing and additive compositing at the same time, it is possible to read Photoshop data with such a layer configuration.

JPEG
 Imports full color and grayscale common JPEG formats. It can also be used as input for the main / mask separation format described below.
Main / mask separation format
 In the main / mask separation format, the main (color information) image and the mask (transparency information) image are in separate files.
 The mask image has the file name of the main image with _m at the end (for example, test_jpg for test.jpg).
 Valid input image formats for the main / mask separation format are BMP, JPEG, and PNG, respectively. The format of the main and mask can be different.

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

Output image format

 The following formats can be used as output image formats.

24bit/32bit BMP
 24bit BMP is a BMP without an alpha channel.
 32bit BMP is a BMP with an alpha channel. It has a main and a mask in one file.
PNG
 A full-color PNG or a PNG with an alpha channel.
TLG5
 Full color TLG5 or TLG5 with alpha channel.

Note
 TLG5 format takes quite some time to compress. It may look like the program has stopped.

TLG6
 Full color TLG6 or TLG6 with alpha channel.

Note
 TLG6 format, like TLG5 format, takes considerably longer to compress. It may look like the program has stopped.

For TLG6 images, tag information is written in the same way as for TLG5 images.
Main / mask separation format
 This method records the main / mask in separate files for images with transparent parts. You can select BMP, JPEG and PNG respectively.
 The mask image has the file name of the main image with _m at the end (for example, test_jpg for test.jpg).
 The main and mask can be in different image formats, but the combination of BMP and BMP, or PNG and PNG is almost meaningless, so it is better to choose the above 32bit BMP or PNG with alpha channel.
 Using JPEG for one or both saves file size, but reduces image quality.
 TLG5 or TLG6 format cannot be specified for the main / mask separation format.

Tag information

The image format converter writes "tag information" to TLG images and PNG images. "Tag information" is information including 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 exported.
mode (TLG only)
Image display mode. For "opaque image", mode=opaque, and if the output format is ltAddAlpha, write the information mode=addalpha.
If the output format is not "ltAddAlpha" for "Images with transparency", mode=alpha will be set if a non-PSD file or a PSD file containing only "Normal" layers is loaded. If you import a layer other than "Normal" in a PSD file, the information corresponding to each blend mode is exported.
In the case of KAG, this corresponds to the mode attribute of the image tag as it is, and becomes the initial value when the mode attribute is omitted in the image tag. In other words, in KAG, even if you do not specify the mode attribute, the mode attribute suitable for the image is automatically set.

 Kirikiri has a dictionary array called imageTagLayerType in the global object of TJS, and shows how the mode of the tag information possessed by the TLG image and the layer type are associated, and is defined as follows.

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       ],
]

 See Graphic system for the type of each layer.
offs_x offs_y offs_unit (TLG, PNG)
 These will only be output if the source is a PNG and the PNG contains information about the offset (oFFs chunk) from the upper left corner of the image.
 offs_x is the distance from the left edge of the horizontal position, and offs_y is the distance from the top edge of the vertical position. offs_unit is either pixel or micrometer and indicates the unit of distance.
vpag_w vpag_h vpag_unit (TLG, PNG)
 These will only be output if the source is a PNG and the PNG contains information about the Virtual PAGe, ie the size of the entire image (vpAg chunk).
 There is an ImageMagick utility as software that outputs this information to PNG. When trimming is performed with this ImageMagick, this information is output as the image size before trimming.
 vpag_w is the horizontal size of the whole image, vpag_h is the vertical size of the whole image, and offs_unit is either pixel or micrometer, indicating the unit of size.
reso_x reso_y reso_unit (TLG, PNG)
 These will only be output if the source is a PNG and the PNG contains information about the image's resolution (pHYs chunk).
 reso_x is the horizontal resolution and reso_y is the vertical resolution. reso_unit is meter, indicating the unit of resolution.

How to use image format converter


 Conversion can be done by dropping the file you want to convert on the image format converter window. You can also drop multiple files.

 You can specify different formats for opaque images and images with transparency.

 The term "opaque image" here refers to an image in which the entire image is completely opaque (for example, a background image used in KAG). An "image with transparency" is an image that has a transparent area (foreground image such as used in KAG).
 Even if the image format has equivalent information, if all pixels of the image are completely opaque as a result, it is treated as an "opaque image".

 After the conversion is completed, a log will be displayed to confirm whether the conversion of each file was successful or an error occurred.

 The following is a description of the screen.

TPC.png

 When executed, the above screen is displayed.

Show options
 When checked, the following settings are displayed. When unchecked, the window will only be at the top, and will be narrow and wide. You can make the window compact if you do not need to set options.
"Opaque image-24bit BMP"
 Select 24bit BMP as the output format for opaque images.
"Opaque image-PNG"
 Select PNG as the output format for opaque images.
"Opaque image-TLG5"
 Select TLG5 as the output format for opaque images.
"Opaque image-TLG6"
 Select TLG6 as the output format for opaque images.
"Opaque image-JPEG"
 Select JPEG as the output format for opaque images.
"Opaque images-JPEG options ..."
 Select the JPEG compression quality when JPEG is selected as the output format for opaque images.
"Image with transparency-32bit BMP (Main + Mask)"
 Select 32bit BMP as the output format for images with transparency information.
"Image with transparency-PNG with alpha channel (main + mask)"
 Select PNG with alpha channel as output format for images with transparency information.
"Image with transparency-TLG5 with alpha channel (main + mask)"
 Select TLG5 with alpha channel as the output format for images with transparency information.
"Image with transparency-TLG6 with alpha channel (main + mask)"
 Select TLG6 with alpha channel as the output format for images with transparency information.
"Images with transparency-Main / Mask separation format"
 Specify the main / mask separation format as the output format of the image with transparency information. Select below what to use for the main / mask. In the case of JPEG, you can select the JPEG compression quality by clicking the "JPEG Option" button.
"Image with transparency-considers input image to be in ltAddAlpha format"
 If this option is checked, the input image will be considered to be in ltAddAlpha format, that is, an additive alpha compositing format suitable for display by specifying ltAddAlpha in the Kirikiri's Layer.type property. The input image formats affected by this option are BMP, PNG, Main / Mask Separation format, PSD format is not affected.
 If this option is not checked, the input image is assumed to be in ltAlpha format. Most graphics software output formats and PNG specifications are in ltAlpha format, so you should not normally check this option.
 If this option is unchecked and "Export in ltAddAlpha format" is checked, the image format converter will convert from ltAlpha format to ltAddAlpha format.
 When this option is checked, the option of "Output in ltAddAlpha format" is automatically checked. Also, the option of "Color information of completely transparent area" is disabled (neither alpha information nor color information is processed by the image format converter).
"Images with transparency-output in ltAddAlpha format"
 If this option is checked, the output image will be output in ltAddAlpha format.
 If this option is unchecked, the output image will be in ltAlpha format, or in the case of input from a PSD file, will be in a format that corresponds to the blend mode of the layers contained in that file.
 Various graphic software and PNG specifications only accept images in ltAlpha format, so if you do not use the output image for Kirikiri, please do not check it normally.
 If this option is checked, the option "Color information for fully transparent areas" will be disabled (no alpha or color information will be processed by the image format converter).
"Images with transparency-color information for fully transparent areas"
 Specifies processing of completely transparent parts of the image.
 Normally, ltAlpha format images have color information even in completely transparent areas. Since that part is completely transparent, it is simply ignored when displaying, but it is not ignored when processing images (including compression by JPEG, etc.).
 Specifies how to handle this completely transparent part.

Removal
 If you specify the removal, the color information of the completely transparent part is removed (exactly, it is filled with black).
 Normally, this is OK.
As it is
 Do not process. The original image remains as it is.
 If there is dust in the completely transparent area, the dust will be compressed, so the compression ratio will be worse.
Synthesis
 The color of the completely transparent part is inferred from the color of the opaque part around it, and then synthesized.
 You can select the synthesis intensity from 1, 2, 3, 5, 8 pixels. Here, the color of the completely transparent part is synthesized from the pixel color of the opaque part within the specified distance in pixel units. Larger values take longer to process. Colors that are completely transparent outside the specified distance will be removed.
 For example, when compressing a main image with JPEG, mosquito noise occurs in places where there is a sudden change in color due to the characteristics of JPEG. In the case of foreground images, if "composite" processing is not performed, and if there is a sudden color change at the boundary between completely opaque parts, it is likely to occur in that part. By performing the "composite" process, the color of the completely transparent part is composited from the color of the opaque part, so the difference in color change can be suppressed and the occurrence of mosquito noise can be suppressed. Also, in general JPEG, color information is mixed with neighboring pixels, but this is also performed by "compositing" processing, so that the color of unintended completely transparent parts (if not combined) and the color of opaque parts Can be kept from mixing.
 Normally select "Remove". No color information is needed for completely transparent areas. If you remove the image, you can reduce the file size of the compressed image.
 This option is disabled if "Output in ltAddAlpha format" is checked. "Completely transparent" in the ltAddAlpha format is because the opacity is 0 and the color can only be black.
"Output folder-same folder as input file"
 Output the file to the same folder as the input file.
"Output folder-specified folder"
 Outputs the output file to the folder specified in the input box below.
 Click the "Browse ..." button to display a dialog box for selecting an output folder.
 If you specify a relative folder in the input field, you can specify a relative position from the folder that contains the input file.
"Output folder-Overwrite if there is a file with the same name"
 If this check box is checked, if there is a file with the same name, it will be overwritten.
"Do not display log if no error occurred"
 If this check box is checked, if the conversion is completed and no error occurs during the conversion, the window for checking the log will not be displayed.
"close"
 Exit this tool.