A recent project encountered a demand: Parse apk and IPA package, and then upload the icon inside the server.
Problem
Parse upload process is relatively simple, I use Jszip to apk and IPA for decompression, and then find inside the icon upload to the server. However, when I use a picture in a Web page, the problem arises. There is no problem with the icon in the APK, but the images that are parsed in IPA can be displayed normally in Safari and cannot be displayed in any other browser.
Reason
Google later found that it is Apple to optimize the PNG image, read this article (view), in the article we can learn some useful information:
Apple uses Pngcursh open Source Library to crush PNG images inside IPA files.
Solution
As a front-end engineer, I would like to use JavaScript to solve this problem. In fact, before someone abroad has to solve, Nodejs-pngdefry is OK, but this too long did not maintain, has not run up.
Can not find available, I have to do their own clothing, to write one. So there was node-pngdefry. Node-pngdefry's function is clear: Use JavaScript to restore the PNG image processed by Apple.
Node-pngdefry usage is simple and supports command line and regular node.js:
Command line usage
Install
Then run:
$ pngdefry-i Icon.png-o icon.new.png
Using in Node.js
$ NPM Install Pngdefry--save-dev
var Pngdefry = require (' Pngdefry ');
var path = require (' path ');
var input = Path.join (__dirname, ' icon.png ');
var output = Path.join (__dirname, ' icon.new.png ');
Pngdefry (input, output, function (err) {
if (err) {return
;
}
Console.log (' success ');
};
Test
Project Address
Node-pngdefry