User blog:Tamamoball/Extracting assets (CG) from arc.nsa files - reformatted

'I am remaking this page in order to fix the formatting issues from the previous version. I had forgotten to do this earlier, but now is as good a time as any, since there will probably be a bunch of images that need uploading/fixing from the most recent part of the English patch.'

Extracting assets (CG) from arc.nsa files

This is a guide on how to extract images from arc.nsa files, while preserving the original image quality, including proper transparency. This method is the best (and likely the fastest) way to obtain high quality, clean looking images for upload to the wiki.

Why not simply have a character pose over a green background and use Magic Eraser to remove the green? Well, consider an image that has transparency, like Promenstein here



This is what happens if you try to use the magic eraser:



This is the result using my method:



'''Recommended software: Crass (download from http://tlwiki.org/index.php?title=File:Crass-0.4.14.0.bin.7z ) 7-zip or Winrar (7-zip is free, Winrar is not but the trial version allows unlimited unpacking of files) Irfanview (free software, google it) Adobe Photoshop (I use CS2, free alternatives may work, I haven't tried)'''

Note: I am using a Windows system, and some things may not work on a different OS.

Step 1: Data extraction
You will need to use an external program to retrieve resources from your arc#.nsa files. Here is how to extract data using Crass. If you are extracting with a different program, the method may differ but you should get the same resulting files. First, extract the crass-0.4.14.0 folder from the .7z file and save it anywhere on your hard drive. Open "CrageGUI.exe". Select "Source file" and browse for the .nsa file which you wish to extract. Alternatively, if you want to extract all the files at once, move your .nsa files into an empty folder, select "Source path" and browse for the folder where the files are stored. Do not check both the "Source file" and "Source path" boxes at once, or you will just waste your time. If you did not set a destination path, the files will be extracted to the Crass folder. The contents of the .nsa file will be in a folder named the same as the original .nsa file (such as arc2). The original .nsa file will not be deleted or altered.

arc.nsa contains the chapter 1 assets, arc1 contains the chapter 2 assets, arc2 the chapter 3 assets, and (correct me if I'm wrong) anything beyond is extraneous and is used by side stories or patches to the game. For example, arc4.nsa contains images for the "Marco's travels" side story.

Step 2: Converting files
Once extracted, the image files will be in .bmp format and the voice clips will be in .ogg format. If you can't play .ogg files, use google to find a player or converter. If you can't view .bmp files, your computer must really suck.

To mass convert images, I recommend using Irfanview. Open Irfanview, and select File -> Batch Conversion/Rename. Make sure to actually select the images you wish to convert and click the "Add" button so that they appear in the list of input files.

For the background images ("bg" folder), I suggest using .jpg as the output format. Click "Start Batch" and the images will be converted.

DO NOT CONVERT THE "chara" FOLDER YET!

Note that the original files will not be deleted or overwritten if the filenames of the converted files are different from the originals. "image1.jpg" is considered a different name than "image1.bmp" so after the batch is completed, both the jpg version and bmp version will exist. You may want to delete the .bmp files to save hard drive space.

Step 3: Character image editing preparations
Open the "chara" folder in Windows explorer. Set the view mode to "details". Sort by filesize. Create new folders and name them based on image dimensions (e.g. 1600x600), and place all images that match those dimensions in the corresponding folder.

Note: I just realized that only the WIDTH values matter, and height does not. For example, an image with a resolution of 1600x600 will work the same as one with a resolution of 1600x640, so you don't actually need to keep those two folders separate.

Here is why you should not convert the file format yet: the filesize of a .bmp is length*width*bitdepth. The bitdepth is (correct me if I'm wrong) always 24 here, so all image with the same area will always have the same filesize.

However, you do still need to be careful: The same area does not always mean the same dimensions. For example, the vast majority of images have the dimensions 1600x600, which is an area of 960000 pixels and filesize of 2813KB. However, some images have the same filesize but different dimensions - for example, "delh_a_st01.bmp" has the dimensions 1200x800, which gives the same area and filesize as most 1600x600 images. To be sure, click "show more details..." in the bottom info bar of windows explorer and make sure it does not say "(multiple values)" for dimensions.

Step 4 (Final): Character image editing
First of all, I suggest setting Photoshop as your default program to open .bmp files while doing this. It saves some time and effort which can be significant if you're editing a lot of files. If you are using any other image-editing program and can't follow these instructions, I can't help you. The following instructions will work for Photoshop CS2 and above; I don't know if they will for lower versions.

Open Photoshop. From my experience you can only edit one image at a time - If you know of a faster way, please tell me.

Select the rectangular marquee tool. Change "Style" from "Normal" to "Fixed Size". Change width to EXACTLY HALF of the size of the image you are editing, and height to 2000px or so, as long as it's greater than the size of the image you are editing.

Make sure the Layers, Channels, and Tools toolbars are visible. They should be by default.

Open the image you want to edit. Maximize your image if it's not already maximized.

'(Recording a bot: Optional step, recommended if editing a large amount of images) Select Window -> Actions to display the Actions toolbar. Click the "New action" button. Set it to a function key like F2 to easily activate it. Click "Record".'

Double-click your Background layer and press OK or select Layer -> New -> Background from layer. Don't bother naming the layer.

Click above the right half of your image to select it.

Press Ctrl-i to invert.

Press Ctrl-x to cut.

Press Alt-Ctrl-c to set canvas size. Click the left anchor arrow. Set width to 50% and height to 100%.

Select Layer -> Layer Mask -> Hide All (or "Reveal All", doesn't matter)

Select the "Channels" toolbar.

Show "Layer 0 Mask".

Hide "RGB".

"Layer 0 Mask" should be active right now. If not, select it so that it is highlighted in blue.

Press Ctrl-v to paste.

Show "RGB".

Hide "Layer 0 Mask".

Select Layer -> Layer Mask -> Apply.

Press Shift-Ctrl-s to Save As.

Change format to PNG.

Click "Save". Interlacing is recommended but not necessary.

Press Ctrl-F4 or Ctrl-W to close the image. Don't save.

'If you took the optional step to record a bot, stop recording at this point. For any further images with the same width, simply press the hotkey you assigned your bot to, and watch the magic unfold. If switching to an image with a different width, rerecord the bot or just adjust the "Set Selection" step.'



You may want to place the image over a background, for example the encyclopedia background. Simply open both the edited character image and the background, then drag the character image onto the background or copy and paste. Make sure to centre the image properly.