FORUMS
Remove All Ads from XDA

Working With .pkm and .atc Files

1,389 posts
Thanks Meter: 2,562
 
Post Reply Email Thread
Hello XDA,

Today I'm going to show you how to work with/convert the .pkm and .atc image files that are included in system apks on recent devices. It's been about a month since I've looked into these formats, so if anybody has since come up with any better/alternative methods, please share them here.

Let's begin...

.pkm
.pkm files are actually a type of ETC1_RGB8 textures. The reason manufacturers are starting to use them, is because they are fully supported by Android, and with the OpenGL ES platform that Android runs, they offer significant overhead savings vs conventional image formats. A lot of people (devs included) probably haven't realized it, but there is actually a tool that comes bundled with the Android SDK for creating .pkm textures. It's called etc1tool, and is a command line utility. Etc1tool is capable itself of converting .pkm files to .png, but unfortunately all the ones I've come across in pre-existing apks are not able to be converted this way. That would be too easy, right? So, here's what we do instead:

-First, you're going to need to download and install Mali GPU Texture Compression Tool from HERE.

-Once you've got it all set up, open it up, go to File > Open, and open up a .pkm file (or several, as it can do batch processing).

-Now, click on the .pkm file you just opened, in the left-hand pane to select it. You should see the image.


-Next, click on the yellow icon towards the upper right of the screen.


-In the window that pops up, copy the settings I have here. You can change the directory (it's only going to store a temp file anyway), but everything else must match.

-Click OK, let it do its' thing, and you should see a screen similar to this:


-Now, you're going to click on your image(s) in the left-hand pane to select them again, then click on the blue save icon towards the upper right.


-Save them to whatever directory, and with whatever extension you'd like (most likely .png). Now, the standard ETC1 format doesn't handle alpha values, and the existing .pkms seem to have been encoded using some proprietary method that preserves the alpha channel. When you save your image from Mali, it will not save the alpha values, despite the preview having them. As a result, your .png will have a black background, similar to this:

From here, though, you at least have a standard .png image, which you can then open with Photoshop or Gimp and easily remove the black background.

-If for some reason you'd like to create your own .pkm file(s) from existing images, navigate in command prompt to the your Android SDK > Tools directory, then use the following:
Code:
etc1tool pathtoinputfile.png --encode -o pathtooutputfile.pkm

.atc
.atc files aren't going to be as common as .pkm, as they are a proprietary format and can only be used on device with a Qualcomm Adreno chipset. Just like .pkm files, they offer significant gains in overhead performance compared to standard image formats, but they are a pain when you're trying to theme an app that's full of them. Let's begin...

-Start off by downloading the ASTC Evaluation Codec found HERE. This one is going to be a zip, rather than an installable program, so download it and extract it wherever you wish. Once extracted, find the location of 'astcenc' (the folder names are odd, and differ depending on your OS).

-Once you've located it, open up command prompt, and navigate to that folder.

-Like etc1tool, the ASTC Codec is capable of converting directly to .png, but also like the .pkm files, it doesn't work in this case. You can try, but the result will be unusable, so don't waste your time. Instead, we're going to convert to .tga.

-So, in command prompt, use the following to decode the .atc to a more usable .tga:
Code:
astcenc -d pathtoinputfile.atc pathtooutputfile.tga


-Unlike .pkm files and Mali, this will preserve any existing transparency, but there's a catch (there's always a catch). The resulting .tga file will be upside down.


-Fortunately, this is nothing more than a minor inconvenience lol. So, once you have your .tga file, open it up in Photoshop or Gimp, flip it, and save as .png, and you should be all set.

-If for some reason you wanted to create a new .atc file, the codec can be used for that as well. I forget the command, and documentation is very hard to find, but if you use the following, you should be able to go from there:
Code:
astcenc -help
Be aware, that there is absolutely no need to recreate any of these special formats. You can simply delete the originals and replace them with .png files of the same name, and they'll work just fine in any apk, and then you won't have to worry about it in the future. Anyway, I hope some of you learned something and find this useful....

~morningstar
The Following 19 Users Say Thank You to Morningstar For This Useful Post: [ View ] Gift Morningstar Ad-Free
 
 
13th April 2015, 04:48 PM |#2  
Carotix's Avatar
Recognized Themer
Flag Ravenna
Thanks Meter: 34,298
 
Donate to Me
More
hi Morningstar , thanks a lot for this work
do you think it is possible to make an apk like qmg2png ?
The Following User Says Thank You to Carotix For This Useful Post: [ View ] Gift Carotix Ad-Free
13th April 2015, 06:57 PM |#3  
Morningstar's Avatar
OP Senior Member
Flag CA
Thanks Meter: 2,562
 
Donate to Me
More
Quote:
Originally Posted by Carotix

hi Morningstar , thanks a lot for this work
do you think it is possible to make an apk like qmg2png ?

Unfortunately, I don't believe so. At least I couldn't. Perhaps someone more knowledgeable might be able to do something like that.
The Following 2 Users Say Thank You to Morningstar For This Useful Post: [ View ] Gift Morningstar Ad-Free
16th April 2015, 11:41 AM |#4  
manikant_009's Avatar
Senior Member
Flag Mumbai
Thanks Meter: 1,217
 
Donate to Me
More
I am not able to convert .atc extension files with your guide it creates a new .tga files but when i open it with Photoshop it gives me error "Could not complete your request because of a problem with the file-format module interface."
The Following User Says Thank You to manikant_009 For This Useful Post: [ View ] Gift manikant_009 Ad-Free
19th April 2015, 10:45 PM |#5  
Morningstar's Avatar
OP Senior Member
Flag CA
Thanks Meter: 2,562
 
Donate to Me
More
Quote:
Originally Posted by manikant_009

I am not able to convert .atc extension files with your guide it creates a new .tga files but when i open it with Photoshop it gives me error "Could not complete your request because of a problem with the file-format module interface."

Interesting. I don't use PhotoShop personally, so I wasn't aware of the issue. What version of PS are you using? I'll see if I can figure out a solution. In the meantime, I guess I'd have to recommend Gimp, as it's what I generally use, and doesn't seem to have any issues opening the resulting .tga files.
22nd April 2015, 06:23 PM |#6  
manikant_009's Avatar
Senior Member
Flag Mumbai
Thanks Meter: 1,217
 
Donate to Me
More
Quote:
Originally Posted by Morningstar

Interesting. I don't use PhotoShop personally, so I wasn't aware of the issue. What version of PS are you using? I'll see if I can figure out a solution. In the meantime, I guess I'd have to recommend Gimp, as it's what I generally use, and doesn't seem to have any issues opening the resulting .tga files.

I Succeeded in Converting .atc files. What I did is just renamed all .atc files to .astc extension and then used Picconv 2.1 to covert it to .png files
The Following 2 Users Say Thank You to manikant_009 For This Useful Post: [ View ] Gift manikant_009 Ad-Free
22nd April 2015, 07:10 PM |#7  
Morningstar's Avatar
OP Senior Member
Flag CA
Thanks Meter: 2,562
 
Donate to Me
More
Quote:
Originally Posted by manikant_009

I Succeeded in Converting .atc files. What I did is just renamed all .atc files to .astc extension and then used Picconv 2.1 to covert it to .png files

Picconv, huh? Never heard of it, but I'll definitely check it out, because the current method is rather convoluted and annoying lol.
27th April 2015, 05:04 AM |#8  
mikeymopar's Avatar
Senior Member
Thanks Meter: 923
 
More
hey @Morningstar...i reworked my batch file i made that resizes a folder full of xxhdpi images to xhdpi and hdpi sizes to now also convert a folder full of atc images to tga, flip them, and convert them all to png images all in one step. maybe it'll help y'all out a little...ionno...maybe.

folder structure must be exactly as shown and explained in the setup.txt file.

Image Converter

EDIT: use V2 edition on page 2 of this thread as i made it to convert .wbp images too now (HERE)
Attached Thumbnails
Click image for larger version

Name:	image converter folder structure.JPG
Views:	578
Size:	127.5 KB
ID:	3283919  
The Following 7 Users Say Thank You to mikeymopar For This Useful Post: [ View ] Gift mikeymopar Ad-Free
28th April 2015, 03:38 AM |#9  
kevinoliva113's Avatar
Senior Member
Thanks Meter: 829
 
Donate to Me
More
Quote:
Originally Posted by mikeymopar

hey @Morningstar...i reworked my batch file i made that resizes a folder full of xxhdpi images to xhdpi and hdpi sizes to now also convert a folder full of atc images to tga, flip them, and convert them all to png images all in one step. maybe it'll help y'all out a little...ionno...maybe.

Great work Mikey.. Just tested. Full disclosure. ......... I'm lazy. I copied all images over. .9s,qmg, and atc. It ignored other formats, and hit every atc. Perfect!!!



Sent from my SM-N910P using XDA Free mobile app
The Following 2 Users Say Thank You to kevinoliva113 For This Useful Post: [ View ] Gift kevinoliva113 Ad-Free
28th April 2015, 05:26 AM |#10  
mikeymopar's Avatar
Senior Member
Thanks Meter: 923
 
More
Quote:
Originally Posted by kevinoliva113

Great work Mikey.. Just tested. Full disclosure. ......... I'm lazy. I copied all images over. .9s,qmg, and atc. It ignored other formats, and hit every atc. Perfect!!!

big thx @kevinoliva113 for the feedback. i'm a bit out of the loop now (haven't dealt with atc before; still on kk with att) and by pure chance noticed someone mentioning how it was so time consuming converting atc images one at a time and yearning for a way to batch convert a bunch of them. so hopefully, at least for the time being, this meets the requirements for those that can use it
The Following 3 Users Say Thank You to mikeymopar For This Useful Post: [ View ] Gift mikeymopar Ad-Free
29th April 2015, 12:20 AM |#11  
Morningstar's Avatar
OP Senior Member
Flag CA
Thanks Meter: 2,562
 
Donate to Me
More
Quote:
Originally Posted by mikeymopar

hey @Morningstar...i reworked my batch file i made that resizes a folder full of xxhdpi images to xhdpi and hdpi sizes to now also convert a folder full of atc images to tga, flip them, and convert them all to png images all in one step. maybe it'll help y'all out a little...ionno...maybe.

folder structure must be exactly as shown and explained in the setup.txt file.

Image Converter

Wow, Mikey, excellent work! Fortunately, I haven't had to deal with too many .atc files, but I know some devices have a ton of them, and that'll be a great time saver.

Fantastic job!
The Following User Says Thank You to Morningstar For This Useful Post: [ View ] Gift Morningstar Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes