If you want to use the p3t library to write your own theme builder for your specific OS you will need to know a little bit about GIM files.
GIM files is the format of all icons (including preview image) in the PS3 theme. Only the background images are stored as pure JPG. GIM files are actually compressed inside the p3t file, but the p3t library will handle the compression. The p3tGIM structure contains a file_data and file_size field. The file_data consists of a 128-byte header followed by RGBA values for every pixel in the image. Therefore a 64x64 image will have 64*64*4+128 bytes of file_data. Please note that the data rows must be multiples of 4 pixels, therefore if you use an image with a width of 6 pixels you must actually read 8*4 bytes for that row and only interpret the first 6*4 bytes.
The format of the header is not completely known to me, but the width and height are stored as WORD values at offset 72 and 74 in the header. What I found was that all GIM headers which has the same dimensions look exactly alike. Therefore you can actually rip the GIM headers for various dimensions and just append the data to the header to create a GIM file.
I hope this makes sense, if it does not play around and see what you can come up with.