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?
2 Answers
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.
- 131
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.
fehloads the image just finegimploads the image, and saves it properly, dropping the extra garbage.convert(fromimagemagickpackage) works well,convert fat.png jcraig.pngstrips 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.
- 11,909