1

When extracting image files from a firmware dump using binwalk, I get a lot of valid pngs. My problem is the following: All those files are extremely large. They start with the correct beginning but are as long as the rest of the dump. How do I cut those files automatically?

bot47
  • 1,922

2 Answers2

2

I had the same question but arrived at a perhaps more elegant answer.

binwalk -D 'png:png:convert %e %e' myfile.bin

That will run the convert program in place on any extracted PNG files.

Edward
  • 131
1

Often you can use an image converter to convert the PNG's to ... PNG's.

Many image 'processors' will read the image based on the headers in the image file itself, which means they'll only read what is needed to load the picture. Then re-save the image, perhaps to a new name.

I created a fat PNG (ha!) by cating several files together, a PNG, and then a 3Meg PDF.

  • feh loads the image just fine

  • gimp loads the image, and saves it properly, dropping the extra garbage.

  • convert (from imagemagick package) works well, convert fat.png jcraig.png strips off the extra.

  • gwenview (KDE app) read and saved the file properly.

I only tried the few applications I could think of that I knew I had installed. The imagemagick utility convert is promising and scriptable.

for f in *.png; do
  convert "$f" "skinny.$f"
done

Probably make light work of your weighty images.

lornix
  • 11,909