This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
FuuuAInfiniteLoop(F.A.I.L)'s profile picture

Compressor

Started by FuuuAInfiniteLoop(F.A.I.L), 09 February 2013 - 04:21 PM
FuuuAInfiniteLoop(F.A.I.L) #1
Posted 09 February 2013 - 05:21 PM
Pastebin ID: DBPST1kP
how to use:

compressor -create sourcefile output
compressor compressedfile

where sourcefile is a file where each line is a file to compress

it makes a file named readme, you can delete it, it there because the program error if i dont make a file before accepting another file

Im making a GUI, post ideas!

Poll added
lieudusty #2
Posted 09 February 2013 - 05:25 PM
Does this make the file size smaller or just packs together a folder?
FuuuAInfiniteLoop(F.A.I.L) #3
Posted 09 February 2013 - 05:28 PM
it makes the file smaller and compress everything to one fille
FuuuAInfiniteLoop(F.A.I.L) #4
Posted 11 February 2013 - 10:45 AM
Launched!
Doyle3694 #5
Posted 11 February 2013 - 11:31 AM
A quick bug report for you:
You change getmetatable to @gm, but @gm to getmetatables. Havn't actually used the compressor but I think that would cause a problem.
PixelToast #6
Posted 11 February 2013 - 11:44 AM
cant compress itself without breaking
this isnt verry good
FuuuAInfiniteLoop(F.A.I.L) #7
Posted 11 February 2013 - 03:25 PM
A quick bug report for you:
You change getmetatable to @gm, but @gm to getmetatables. Havn't actually used the compressor but I think that would cause a problem.

Fixed! thanks for the bug report

cant compress itself without breaking
this isnt verry good
you try compressing it with another copy of the porgram?
superaxander #8
Posted 12 February 2013 - 04:45 AM
Does serialising make things smaller?
theoriginalbit #9
Posted 12 February 2013 - 04:48 AM
Does serialising make things smaller?
Nope, not one bit.
but because the data is read into a table, the only way to write a table to a file is to serialize it…
FuuuAInfiniteLoop(F.A.I.L) #10
Posted 12 February 2013 - 05:10 AM
Does serialising make things smaller?
it replaces large word to two or therre letters si ts smaller(like the comprssion on lightshot)
Lyqyd #11
Posted 12 February 2013 - 06:41 AM
Have you done any file size comparisons? I very much doubt that this would provide a significant compression ratio.
Kingdaro #12
Posted 12 February 2013 - 09:47 AM
Don't think this is the best method of actual compression - if anything, you didn't chose very common keywords at all.
PixelToast #13
Posted 12 February 2013 - 09:56 AM
and now im gona make my own compression…
FuuuAInfiniteLoop(F.A.I.L) #14
Posted 12 February 2013 - 02:56 PM
Pool added!
PixelToast #15
Posted 12 February 2013 - 03:57 PM
what do you mean by zip compression with http?
FuuuAInfiniteLoop(F.A.I.L) #16
Posted 13 February 2013 - 02:37 AM
I will compress the file in the program and i will send that file to a php script that will compress it in .zip and show it in the screen so i can write it to a file in the computer and whit decompression too
PixelToast #17
Posted 13 February 2013 - 02:40 AM
will it be real .zip compression >_>
if then yes
FuuuAInfiniteLoop(F.A.I.L) #18
Posted 13 February 2013 - 02:50 AM
will it be real .zip compression >_>
if then yes

while true do
  if poll then
	 if poll.yes > 5 then
	    print("I will do it")
	 elseif poll.no > 5 then
	    Print("Cancelled")
	 else
		 sleep(4)
	 end
  end
end
FuuuAInfiniteLoop(F.A.I.L) #19
Posted 13 February 2013 - 04:51 AM
I have made a site where you can compress then if anybody can help to integrate this to the code will be credited(when i finish the credits)
the site is
luazipcompress.webuda.com/compress.php

compress.php can compress strings if called

luazipcompress.webuda.com/compress.php?file=string&mode="compress"
or decompress

luazipcompress.webuda.com/compress.php?file=string&mode="decompress"

code:

<?php
if ($_GET["mode"]=="compress") {
echo gzcompress($_GET["file"], 9);
} elseif ($_GET["mode"]=="decompress") {
echo gzuncompress($_GET["file"]);
}
?>
PixelToast #20
Posted 13 February 2013 - 05:38 AM
remove the quotes around compress and decompress in the url example, that was derp on my part .-.

and please use $_POST instead of $_GET

and use this instead of before:

http.request("luazipcompress.webuda.com/compress.php","file="..textutils.urlEncode(string).."&mode=compress")

EDIT: your site is already down *sigh*
please implement some sort of length limit
tesla1889 #21
Posted 14 February 2013 - 01:18 PM
you know, it would be WAAAAAAY more effective to use huffman tables to compress the actual bytes of the text. it decreases the file size by a lot.

you take the bytes and arrange them in a table from most used to least used.

then, for every byte of text, you put the byte's table location of 1s followed by a 0.

append all of the bytes in the table to the binary stream

the most used bytes will compress down the most, following the series:

10, 110, 1110, 11110, 111110, 1111110, 11111110, …
immibis #22
Posted 22 February 2013 - 08:11 PM
you know, it would be WAAAAAAY more effective to use huffman tables to compress the actual bytes of the text. it decreases the file size by a lot.

you take the bytes and arrange them in a table from most used to least used.

then, for every byte of text, you put the byte's table location of 1s followed by a 0.

append all of the bytes in the table to the binary stream

the most used bytes will compress down the most, following the series:

10, 110, 1110, 11110, 111110, 1111110, 11111110, …
That's not Huffman coding.
tesla1889 #23
Posted 23 February 2013 - 03:40 AM
–snip–
That's not Huffman coding.

oh. k. when i read up on zip compression, that's what it said.
wilcomega #24
Posted 24 February 2013 - 06:44 AM
pretty cool program you made. i see the point of compressing but its not really needed with the amount of memory computers and disks have.
superaxander #25
Posted 25 February 2013 - 09:13 PM
Still needing to implement it i can help.
FuuuAInfiniteLoop(F.A.I.L) #26
Posted 26 February 2013 - 02:24 PM
If you give me a php code(because im not very good at php) for zip compression a a way to pass information using http api i will add zip support
Sxw #27
Posted 26 February 2013 - 04:40 PM
I can't do php or zip, but I can write a zlib program in node.js and host it, if you'd like.
immibis #28
Posted 26 February 2013 - 07:25 PM
I compressed my own compressor with this one and it came out 0.097% bigger than it started as.







tesla1889 #29
Posted 27 February 2013 - 06:16 PM
I compressed my own compressor with this one and it came out 0.097% bigger than it started as.

compressors work best with large files. try it with a 1MB or larger file
GravityScore #30
Posted 27 February 2013 - 08:38 PM
I compressed my own compressor with this one and it came out 0.097% bigger than it started as.

compressors work best with large files. try it with a 1MB or larger file

Where can you find a program that's 1MB? The only one I can think of right now that is over that is the secret along time ago movie, which is 2MB. If a compressor in CC only worked with files above 1MB, it'd be pretty useless…

I'm pretty sure that compression works with files above 2KB, and from memory, immibis's compression software is 5KB (I think :P/>).
immibis #31
Posted 27 February 2013 - 10:18 PM
compressors work best with large files. try it with a 1MB or larger file

Where can you find a program that's 1MB? The only one I can think of right now that is over that is the secret along time ago movie, which is 2MB. If a compressor in CC only worked with files above 1MB, it'd be pretty useless…

I'm pretty sure that compression works with files above 2KB, and from memory, immibis's compression software is 5KB (I think :P/>/>/>).

rom/programs/secret/alongtimeago comes out 6.39% bigger than it started as.
theoriginalbit #32
Posted 28 February 2013 - 12:30 AM
I compressed my own compressor with this one and it came out 0.097% bigger than it started as.
How much smaller/bigger does yours make it?
Xtansia #33
Posted 28 February 2013 - 12:57 AM
I compressed my own compressor with this one and it came out 0.097% bigger than it started as.
How much smaller/bigger does yours make it?

If you read his thread you'll see:
immibis said:
This compressor compresses itself at 67%, which could easily be improved to 50% if LuaJ didn't mangle non-ASCII characters.
For comparison, 7-Zip is able to compress the compressor program at a ratio of 35% (lower is better), and urielsalis's compressor achieves a whoppingly useless 100.097%
Divide_By_0 #34
Posted 11 March 2013 - 02:28 PM
cant compress itself without breaking
this isnt verry good
LOL
MewK #35
Posted 12 March 2013 - 05:35 AM
Maybe you're interested in this:
https://github.com/davidm/lua-compress-deflatelua

It's basically gzip in pure LUA. Just proposing it because I know I would never use a compression programming relying on a web server.

Good luck!
TheOddByte #36
Posted 18 April 2013 - 12:18 PM
Pool added!
Lol, Can I swim in it? :P/>

But back on topic..
I haven't tested this but I'm sure that it's better than one I would create.
Dlcruz129 #37
Posted 18 April 2013 - 01:05 PM
Pool added!
Lol, Can I swim in it? :P/>/>

But back on topic..
I haven't tested this but I'm sure that it's better than one I would create.

It's not. It enlarges files instead of compressing them.
SuicidalSTDz #38
Posted 18 April 2013 - 01:14 PM
It's not. It enlarges files instead of compressing them.
I find compressors in CC to be pointless. What files would ever be large enough to need compression? No program on the forum is anywhere near as large as it would need to be for compression.
Dlcruz129 #39
Posted 18 April 2013 - 02:13 PM
It's not. It enlarges files instead of compressing them.
I find compressors in CC to be pointless. What files would ever be large enough to need compression? No program on the forum is anywhere near as large as it would need to be for compression.

Exactly. And I've maxed out disk/computer storage in the config.