0
votes

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

1
File that contains what? How big is it? - netcoder
Various files, like text files or images. Maybe from 7zip/LZMA2 SDK can be create this small application? - Fallen Angel
Strange, why no "experts" here about this topic. I'm surprised. - Fallen Angel
You don't seem to know about how data compression works, and you're asking us to write code for you. I'm not surprised. - netcoder
Netcoder: NO, I just finding any program to do that what I described. Like a small program with 7zip or same algorithm WITHOUT file management, only compress data string/stream. - Fallen Angel

1 Answers

1
votes

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