GimConv

From PS3 Developer wiki
Jump to: navigation, search

Description[edit]

GimConv v1.20h was released with p3tcompiler v2.00 as part of the PS3 Custom Theme Toolbox

Is the responsible of the .GIM image conversions that are used inside Resource Container (RCO) files, PlayStation 3 Theme (P3T) files, etc...

Usage[edit]

The command line help of GimConv.exe displays a very limited list of options with an small explain, some are generic for the tool usage, and others works as lables that loads one option or a group of options from the config file (GimConv.cfg)

Type This
C:\PS3_Custom_Theme_v200\GimConv>GimConv.exe
gimconv ver 1.20h --- generic picture converter
 Copyright (C) 2006 Sony Computer Entertainment Inc.
  All Rights Reserved.

usage:
        gimconv <input files> [options]

options:
        -interact       input additional options
        -pictures       merge files as pictures
        -frames         merge files as frames
        -levels         merge files as levels
        -prompt         prompt always
        -warning        prompt on warning
        -error          prompt on error
        -viewer         start gimview.exe when process ends
        -o <filename>   specify output file name
        -s <w,h>        resize image data
        -S              output text format
        -P              resize image data to a power of two
        -N              output in normal pixel storage format
        -F              output in faster pixel storage format
        -R              re-convert ( don't swap RGBA <-> ABGR )

GimConv.exe[edit]

By specifying an option, or a group of options from command line by his labels (using the names that appears in the help screen, or using the names that appears inside the GimConv.cfg file)

Type This
gimconv.exe test.png -o test.gim --DXT
  • Note the DXT label at the bottom of GimConv.cfg is composed by 3 options:
    • Warning: the option -DXT has been deleted in the GimConv.cfg provided with rcomage, for more detailed changes in that custom GimConv.cfg file see the Discussion page
Codecode
option -DXT {
	pixel_order = default
	pixel_channel = default
	image_format = default
}

By specifying the options strictly from command line (using the names that appears inside the GimConv.cfg file). This is the most accurate way to specify options and to have full controll of all the gim settings

Type This
gimconv.exe test.png -o test.gim --format_style psp --format_endian big --pixel_order normal
  • Note the 3 options used in the example are overriding the default settings at top of GimConv.cfg:
Codecode
//----------------------------------------------------------------
//  default settings
//----------------------------------------------------------------
	pixel_order = default		// default normal faster
	format_style = psp		// std psp ps3
	format_endian = little		// little big

By sending .gim settings from rcomage.exe ---to---> gimconv.exe when compiling the .rco (see the "compile" help in rcomage page). There are 2 options in rcomage specific for this task, named: --gimconv-cmd and --gimconv-flags

Type This
rcomage.exe compile test.xml test.rco --gimconv-cmd ".\gimconv\gimconv.exe" --gimconv-flags "--format_style psp --format_endian big --pixel_order normal"

GimConv.cfg[edit]

This is the configuration file that defines the help screen, and contains the default values and all available options. The next example is the configuration file provided by sony as part of the PS3 Custom Theme Toolbox

Codecode
//================================================================
//  gimconv configuration
//================================================================
 
usage {
	puts "usage:"
	puts "        gimconv <input files> [options]"
	puts ""
	puts "options:"
	puts "        -interact       input additional options"
	puts "        -pictures       merge files as pictures"
	puts "        -frames         merge files as frames"
	puts "        -levels         merge files as levels"
	puts "        -prompt         prompt always"
	puts "        -warning        prompt on warning"
	puts "        -error          prompt on error"
	puts "        -viewer         start gimview.exe when process ends"
	puts "        -o <filename>   specify output file name"
	puts "        -s <w,h>        resize image data"
	puts "        -S              output text format"
	puts "        -P              resize image data to a power of two"
	puts "        -N              output in normal pixel storage format"
	puts "        -F              output in faster pixel storage format"
	puts "        -R              re-convert ( don't swap RGBA <-> ABGR )"
}
 
//----------------------------------------------------------------
//  default settings
//----------------------------------------------------------------
 
default {
	load "lib/*"
 
	//  main control
 
	interact_mode = off		// off on ctrl
	merge_mode = off		// off picture frame level plane
					// image palette sequence
	prompt_mode = off		// off on warning error
	output_object = on		// off on
	output_script = off		// off on
	output_directory = auto		// current input auto
	output_filename = ""
	object_extension = .gim
	script_extension = .gis
	userdata_extension = .dat
	glob_extension = .dds .tm2 .tga .bmp .avi
	object_viewer = ""
 
	//  process control
 
	filter_script = "Filter"
	image_size = default		// default pow2 $w,$h
	pixel_order = default		// default normal faster
	pixel_alpha = default		// default $alpha
	pixel_channel = default		// default rgba rgab ragb ... etc
	image_format = default		// default rgba8888 rgba4444 rgba5551 rgba5650
					// index4 index8 index16 index32
					// dxt1 dxt3 dxt5 dxt1ext dxt3ext dxt5ext
	palette_format = default	// default rgba8888 rgba4444 rgba5551 rgba5650
	update_userdata = default	// default off on
	update_fileinfo = off		// default off on
 
	check_limit = on		// off on
	limit_image_width = 4096	// off $count
	limit_image_height = 4096	// off $count
	limit_level_count = 8		// off $count
	limit_frame_count = off		// off $count
 
	//  output control
 
	format_style = psp		// std psp ps3
	format_endian = little		// little big
 
	output_image = on		// off on
	output_palette = on		// off on
	output_sequence = on		// off on
 
	//  PS3 OSD default settings
 
	format_endian = big		// -B
	pixel_order = normal		// -N
	pixel_channel = default		// -R
	image_format = rgba8888		// --image_format rgba8888
 
	extend_edge = off
}
 
//--------------------------------------------------------
//  format specific
//--------------------------------------------------------
 
input *.avi {
	pixel_alpha = 255
}
 
input *.bmp {
	pixel_alpha = 255
}
 
input *.dds {
}
 
input *.tga {
}
 
input *.tm2 {
}
 
input *.gim {
}
 
input *.gis {
}
 
//--------------------------------------------------------
//  mode option
//--------------------------------------------------------
 
option -interact {
	interact_mode = on
}
 
option -pictures {
	merge_mode = picture
}
 
option -frames {
	merge_mode = frame
}
 
option -levels {
	merge_mode = level
}
 
option -planes {
	merge_mode = plane
}
 
option -images {
	merge_mode = image
}
 
option -palettes {
	merge_mode = palette
}
 
option -sequences {
	merge_mode = sequence
}
 
option -prompt {
	prompt_mode = on
}
 
option -warning {
	prompt_mode = warning
}
 
option -error {
	prompt_mode = error
}
 
option -viewer {
	object_viewer = "GimView.exe"
}
 
//--------------------------------------------------------
//  process option
//--------------------------------------------------------
 
option -o %filename {
	output_filename = %filename
}
 
option -s %size {
	image_size = %size
}
 
option -g %ext {
	glob_extension = %ext
}
 
option -P {
	image_size = pow2
}
 
option -N {
	pixel_order = normal
}
 
option -F {
	pixel_order = faster
}
 
//--------------------------------------------------------
//  PS3 OSD specific options
//--------------------------------------------------------
 
option -B {
	format_endian = big
}
 
option -X {
	pixel_channel = abgr
}
 
option -R {
	pixel_channel = default
}
 
option -DXT {
	pixel_order = default
	pixel_channel = default
	image_format = default
}
 
option -E {
	extend_edge = on
}
 
//--------------------------------------------------------
//  output option
//--------------------------------------------------------
 
option -S {
	output_object = off
	output_script = on
}
 
//--------------------------------------------------------
//  filter script
//--------------------------------------------------------
 
script Filter %target {
	RescaleImage   %target $image_size
	SetPixelFormat %target $image_format $palette_format
	SetPixelAlpha  %target $pixel_alpha
	SwapPixelChannel %target $pixel_channel
	ConfigureImage %target order $pixel_order
	UpdateUserData %target $update_userdata
	UpdateFileInfo %target $update_fileinfo
	ExtendEdge     %target $extend_edge
	CheckPSP       %target $check_limit
}

Note there are some modifications made officially by sony at a later version because GimComv was initially made for PSP (those initial GimComv versions compatibles with "PSP only" probably didnt had this PS3 specific settings), but this public release of GimConv was released as part of a toolkit to build PS3 themes so it has some settings specific for PS3

This group at top on the config file are default settings (for PS3) that overrides other default settings of an older version of GimComv (for PSP). They are overwriting default values because the same option is specifyed before in the file, so the last one overrrides the previous one with the same name (and also was added a new option named extend_edge that should be PS3 specific)

Codecode
//----------------------------------------------------------------
//  default settings
//----------------------------------------------------------------
 
	//  PS3 OSD default settings
 
	format_endian = big		// -B
	pixel_order = normal		// -N
	pixel_channel = default		// -R
	image_format = rgba8888		// --image_format rgba8888
 
	extend_edge = off

This other group seems to be options for GIM formats used in PS3

Codecode
//--------------------------------------------------------
//  PS3 OSD specific options
//--------------------------------------------------------
 
option -B {
	format_endian = big
}
 
option -X {
	pixel_channel = abgr
}
 
option -R {
	pixel_channel = default
}
 
option -DXT {
	pixel_order = default
	pixel_channel = default
	image_format = default
}
 
option -E {
	extend_edge = on
}

Custom configurations[edit]

The configuration file allows to modify the help screen of the command line by adding custom labels, or by removing useless options to make room for more custom labels, this labels can be composed of groups of options, there is no need at all to do this because doesnt really enables any new funcionallity as you can specify all the options you need one by one from command line included the hability to override default values, but is good to keep a record of the most common used formats for a console by using custom labels with intuitive names that defines the GIM format

The config file supplyed by Rcomage contains some custom options for the formats that are used in PSP, some changes in the default settings that was common for PSP (included a size limit that breaks compatibility with PS3), and a group of options was added for PS3 (labeled -ps3) but this group seems to use wrong options. For more info about the modifications made in the config file supplyed with rcomage see the differences in the Discussion page

This wiki section proposes new groups of options with new label names (to be able to use a new modifyed config file without breaking the compatibility of other tools that uses rcomage as a dependency)

The label names proposed here doesnt makes sense at this point, feel free to add more groups of settings with any label name following this same method, also add some info about how many images uses this format (if posible)

  • Inside explore_plugin_full.rco from firmware 4.70 there are 245 images, 201 of them (included the new icon tex_psn.gim) has been made by using this options:
Codecode
option -ps3bpp32 {
	format_style = psp
	format_endian = big
	image_format = rgba8888
	pixel_order = normal
	pixel_channel = default
	pixel_alpha = default
}
  • Inside explore_plugin_full.rco from firmware 4.70 there are 245 images, 30 of them has been made by using this options:
Codecode
option -ps3osdold {
	format_style = psp
	format_endian = big
	image_format = rgba8888
	pixel_order = normal
	pixel_channel = default
	pixel_alpha = default
	update_fileinfo = on
}
  • Inside explore_plugin_full.rco from firmware 4.70 there are 245 images, 14 of them has been made by using this options:
Codecode
option -ps3dxt5 {
	format_style = psp
	format_endian = big
	image_format = dxt5
	pixel_channel = default
	pixel_alpha = default
}
  • Any other (this 2 options seems to be common for all ps3 4.70 rco's)
Codecode
option -ps3wiki2 {
	format_style = psp
	format_endian = big
	image_format = ?
	pixel_order = ?
	pixel_channel = ?
	pixel_alpha = ?
}

How to identify GIM settings[edit]

  • GIM--->GIM method (prefered)
    • Use gimconv with .gim files as input and output (this preserves dxt pixel info, because dxt images doesnt suffers a conversion)
Type This
gimconv.exe test.gim -o test.gim --format_style psp --format_endian big --image_format dxt5 --pixel_channel default --pixel_alpha default
  • GIM--->PNG--->GIM method (fails when there is involved a DXT conversion because DXT conversions are lossy, works fine for rgba**** image formats):
    • Use rcomagegui to make an extraction of the contents without conversion of images (this way the GIM are extracted as GIM)
    • Use rcomagegui to make another extraction of the contents with conversion of images (this way the GIM are extracted as PNG)
    • Use gimconv to convert a PNG ---to---> GIM by the old method of test-error by trying some of the options availables that appears in gimonv.cfg
    • Use a hexeditor to compare the original GIM extracted in step 1 with the rebuilt GIM from your test, there is no need to make accurate comparisons, just an overview of the first 0x80 bytes of the header, and how the pixel data is ordered starting at offset 0x80
    • When the header and pixel data seems similar make a hash comparison, original GIM and rebuild GIM should be exactly the same hash (is posible to create a GIM exactly like the original)
  • By using GimConv.exe with the -S option
    • This generates a .GIS file (is a text based file that contains info about the .GIM file, included all the pixel data)
Type This
GimConv\GimConv.exe -S test.gim -o test.gis

GIM formats used in PS3[edit]

PS3 uses at least 2 types of GIM images, both included inside rco's, and in some cases both types in the same rco

When an .RCO contains 2 or more images that was created with different .GIM settings... it means is not posible to compile the .RCO with rcomage by using .PNG images as source (because rcomage.exe sends the GIM settings to gimconv.exe to make the PNG--->GIM image conversion and this settings are applyed to all PNG images)

In other words, the only way to compile this RCO's is in 2 steps. In the first step is needed to make the different .GIM conversions with gimconv.exe (and all the other conversions in case exists .VAG audio a WAV2VAG conversion or a JS2VSMX for the .VSMX script). In the second step is needed to compile the .RCO with rcomage.exe by using the .GIM's .VAG's and .VSMX's as sources without any kind of file conversions

Also means we have a big problem to document in wiki wich settings are used for each image (there are thousands of images so initially seems not posible), but probably they follows a rule, so the solution is to deduce or imagine the real reason of why the ps3 is using different gim formats inside the .rco's

image group or rco gim settings notes
ps3bpp32 --format_style psp --format_endian big --image_format rgba8888 --pixel_order normal Most used GIM format inside .rco's
ps3dxt5 --format_style psp --format_endian big --image_format dxt5 Second most used GIM format inside rco's

Notes about explore_plugin_full.rco from firmware 4.70:

  • There are 245 images
    • 201 was created by using options: --format_style psp --format_endian big --image_format rgba8888 --pixel_order normal (exact match of gims after rebuilding gim--->png--->gim)
    • 030 was created by using options: --format_style psp --format_endian big --image_format rgba8888 --pixel_order normal --update_fileinfo on (exact match of gims after removing footer from originals and rebuilding gim--->png--->gim)
    • 014 was created by using options: --format_style psp --format_endian big --image_format dxt5 (exact match of gims after rebuilding gim--->gim)
      • item_tex_trophy.gim, trophy_tex_grade_bronze.gim, trophy_tex_grade_gold.gim, trophy_tex_grade_hidden.gim, trophy_tex_grade_platinum.gim, trophy_tex_grade_silver.gim, item_tex_CardBallon.gim, item_tex_Profile_Game.gim, item_tex_Profile_Highlight.gim, item_tex_Profile_Onlines.gim, tex_indi_Me.gim, tex_sb_base.gim, tex_sb_base_s.gim, tex_sb_slider.gim

This is the footer of item_tex_cam_icon.gim (was added to the gim by enabling update_fileinfo option, variable size)

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00006AD0  00 FF 00 00 00 00 00 4C 00 00 00 4C 00 00 00 10  .ÿ.....L...L....
00006AE0  53 70 61 6E 61 2E 74 67 61 00 73 30 30 30 39 33  Spana.tga.s00093
00006AF0  37 00 53 75 6E 20 41 70 72 20 32 33 20 31 38 3A  7.Sun Apr 23 18:
00006B00  33 39 3A 34 38 20 32 30 30 36 00 47 69 6D 43 6F  39:48 2006.GimCo
00006B10  6E 76 20 31 2E 32 30 65 00 00 00 00              nv 1.20e....

And this is the footer of a rebuild gim where the footer was added in the rebuild process

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00002300  00 FF 00 00 00 00 00 54 00 00 00 54 00 00 00 10  .ÿ.....T...T....
00002310  74 65 78 5F 70 73 6E 2E 70 6E 67 00 41 64 6D 69  tex_psn.png.Admi
00002320  6E 69 73 74 72 61 64 6F 72 00 53 61 74 20 4D 61  nistrador.Sat Ma
00002330  72 20 30 37 20 30 31 3A 33 32 3A 30 31 20 32 30  r 07 01:32:01 20
00002340  31 35 00 47 69 6D 43 6F 6E 76 20 31 2E 32 30 68  15.GimConv 1.20h
00002350  00 00 00 00                                      ....

It seems the reason why this images are slighty different is because are ancient (has not been updated lot of firmwares ago, and uses the format from the first firmwares)

As interesting details, in the footer of original files it can be seen the name and format of the original image (.tga), the windows user name, timestamp (from 2006), an the version of GimConv (an old 1.20e)

The 00 00 00 4C (repeated 2 times) at top of the footer in the original gim example is the size of the whole footer (usefull to make the calculation to remove the footer and update the filesize at gim header)

Speculation[edit]

Initially... it seems the gim format depends of who is the responsible of displaying them (as an example, in the link above it seems the images reported as "rare" belongs to "tex_indi_***" (are textures for the "indicator", is the information bar at top-right of xmb, are the tiny icons that appears eventually when you receive a message, etc..)

Note is posible to group them based in how his names starts, all "tex_indi" belongs to indicator so should share the same gim format, even if there are more "tex_indi" inside other rco's, doesnt matters in wich .rco are located what matters is his purpose is the same (to be displayed inside the indicator) This assumption seems wrong