简体   繁体   中英

7zip string/stream compression PHP/C? No file name / date store in .7z archive, every byte count

I want compress 1 small file/data, only file size matter. No need file information store, like filename, size, date, etc...

If I use rar/7zip/zip as CLI, file information added to archive. It's not good for me. I finding the BEST compression solution for file size.

In PHP I can use gzdeflate() or bzcompress() to compress string then save to file as compressed. I finding a same or CLI solution. Environment: Linux, 32/64 bit.

I want to use 7zip/7za as same for string/stream compression.

If I using a binary version of 7z, for example: 7za a -mx9 output.7z input.dat

But this time in .7z found file/date/size information and file size is bigger.

How can I use 7zip or other better compressor like as bzcompress or gzdeflate to compress data stream only, without file informations?

Maybe I cannot use 7zip actually in PHP because not supported yet.

Someone can recommend/create a small C/C++ CLI application/source or in other language what can usable in Linux CLI to compress 1 file and output to 1 file?

For example I want shell exec:

7zcpp input.dat output.7z or 7zcpp -mx9 input.dat output.7z

Summary: Compression speed not important, only better, smaller file size. I want compress only 1 file (string/stream), every byte count, no need filename/date information inside the archive. I can use any better compressor than 7zip, but I think this is one of best actually. Any ideas, recommendations?

Thanks

7Zip memory compression functions - You could check out their SDK and try to look through the functions, - In (C, C++, Java and C#, too bad no php, unless you create your own php extension to bring 7z functionality into your app). In the LZMA SDK, go through the path C\\Util\\Lzma, find the LzmaUtil.c, it's a perfect example to help you . But I've personally used zlib, lzma compresses to 8% of data set size, compared to zlib's 12%, even though zlib is much faster. But since you don't give a shit about speed, lzma is best for you then

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM