The imgtool utility is another one of the tools I'm including in my book, this time to accompany the chapter about the Boot process. I deal a lot with the internal format of images there, and realized I needed a quick extractor. This became more important when I started to deal with the L preview, and Google Glass system images I used for research.
You can get the tool right here. Just unpack the tar. There's a Mac OS X and Linux ELF32/64 binary, and the source. As usual, you might want to check out the RSS feed, or follow my company's Twitter for more updates.
Why should I care?
Well, most users wouldn't. But if you need a quick tool to unpack Android images, this is useful. Think of it as the inverse of mkbootimg (from the AOSP), coupled with simg2img (the sparse image extractor). Another bonus feature it provides is unpacking the Linux bzimage kernels.
Another reason - If you're downloading a rooting tool - and you want to avoid getting malware. I just downloaded An NVIDIA Shield root image, for example - which is really nothing more than a bootimg. So it was trivial to run this tool to extract it - specifically, get to the ramdisk, then cpio -ivd and make sure I can have a peek at it before installing.
So how do I use it?
To obtain an Android system image, you can either get it from a zip (e.g. Google's update, Amazon's update.bin, etc), or by dd'ing for a device, then copying it over. Note that some devices (e.g. the HTC One M8) may need a bit of processing, in this case stripping the 256 header HBoot uses:
If you're using the Google images, it's easier:
You can also use it to extract the filesystem image (basically, do what simg2img does:
Lastly, you can use it for imgdata extraction as well (as the file format there is derived from that of the boot image:
Version 0.2 Changes
Supports offset= (for HTC and other boot.imgs where ANDROID! is wrapped)
The book has a TON of detail about the format of the boot images, as well as customizing the boot process by tinkering with the boot loader, system.img, and what not. The book has been out for a while, and you can get it on this very site, or on Amazon.
Volume II - covering the deep internals of the frameworks and the runtime - will be out around the time M N goes final. In the interim, I encourage you to try out the tool (as well as the even more powerful Dextra, and the simple but useful bindump) and, of course - JTrace. Shoot me an email (to j@) if you've any questions. Or comments. Or in general. All are welcome.