

That allows you to develop programs that are custom-tailored to your own unique needs. Also, you'll need to use line commands if you want to write scripts. I use line commands because they give you complete control over compression and format conversion features. This article demonstrates how to use Linux line commands to perform the most common space-saving conversions. Have media files on your computer? You can likely reclaim significant disk space by storing that data in more space-efficient file formats. The code uses inet.h for htonl() to de- endian-ize the header byte ordering. (Consider the code carefully before feeding it a directory full of arbitrary PNGs of course.) This method is much faster than using a library which loads the PNG forwards, backwards and sideways just to get the image size :P If ((fd = open(argv, O_RDONLY)) = -1) oops("open") #define oops(syscall) įor (i = 1 i 2) printf("%s: ", argv) > 0.00user 0.00system 0:00.03elapsed 12%CPU (0avgtext+0avgdata 1904maxresident)kĠinputs+0outputs (0major+160minor)pagefaults 0swaps > 0.56user 0.22system 0:06.77elapsed 11%CPU (0avgtext+0avgdata 25648maxresident)kģ4256inputs+0outputs (119major+2115minor)pagefaults 0swapsīy reading only the bytes necessary, this operation can be significantly sped up.

A small test: $ du -h *.png -total | tail -n 1 Both display and file are quite slow, and have the potential to bring even quite capable systems to their knees dealing with many multiple files.
