Compressing Technique by converting it into images (New Compression Technique)

Discussion in 'General Chat' started by Freewebspace, May 13, 2009.

  1. #1
    Compressing Text by Images
    This is an algorithm that can be used to Compress files.This can be used to compress the files by converting files into images.

    Note:This is my own technique and I did n’t copy it from internet

    Zip format and Rar format:
    You must have heard about Zip and RAR formats which are used to compress files so that they occupy smaller space.Those Zip and RAR formats use Central Directory and insert a backdoor entry for those

    My format:

    Compression:

    This algorithm can be used to compress characters by converting them into pixels of a image.E.g 3 characters in the file are converted into RGB values of a pixel and pixels are combined to get a image

    RGB- Red,Green,Blue values of a pixel.Each pixel is defined by it’s RGB values .In real time there are 256X256X256 colors

    (compressed format)

    Decompression:

    The pixels of the image(compressed) are read by the script and the RGB values are converted into characters.


    Steps involved in it
    :

    First Step:
    Get the Contents of the File.

    Second Step:
    Split the characters in the file into chunk of 3.

    Third Step:
    Get the count of chunks

    Fourth Step:
    Convert of each of the character into Decimal using ASCII table

    Fifth Step:
    Then set the pixel it a particular point using (R,G,B)

    Sixth Step:
    Then increment it to next level

    Seventh Step:
    Then repeat steps 4-7 for another chunk.

    Eight Step:
    Join the pixels to get the image

    .

    E.g
    Let us take the word Sachin
    Step 1:
    “Sachin”

    Step 2:
    1—>”Sac”
    2—>”hin”

    Step 3:
    Count of chunks:2 (Since “Sac”,”hin”)

    Step 4:

    For Sac:
    Converting each character into ASCII value
    So
    “Sac”==>”83,97,99″
    “hin”==>”104,105,110″

    step 5:
    RGB values of pixel at x=1 and y=1 would be (83,97,99) ===>(Sac)
    RGB values of pixel at x=2 and y=1 would be (104,105,110)===>(hin)

    Step 6:
    these pixels would be combined to form a image..

    Decompression:

    Step 7:

    pixels of the image would be read by the script and converted into RGB values
    In this case
    pixel 1: (83,97,99)
    pixel 2: (104,105,110)

    Step 8:
    RGB Values would converted to ASCII characters

    83---->S
    97---->A
    99---->C
    104--->H
    105--->I
    110--->N

    We will get the original Text.."SACHIN"


    Compression:
    This algorithm is used to compress characters by converting them into pixels of a image.E.g 3 characters in file are converted into RGB values of a pixel and pixels are combined to get a image

    Decompression:
    Pixels are converted into characters and they are joined at the end to get the original file.

    Results:
    Original File Size:3.00 MB
    Zip:2.35 MB
    My format~2.40 MB

    Difference is just 2~4% between my format and Zip. I think this can be further reduced by using mathematical techniques in reducing the RGB values which is possible..


    I was able to reduce a 721 KB Media file into 649 KB file by manipulation techniques..(Zip format and Rar format were able to reduce only to 700KB)

    I think someone better than me who have more time would be able to bring in some new methods using this algorithm.

    Files are attached with this thread..

    a)There would be two variables sourcefilename and targetfilenamesourcefilename=>name of the file that would be compressed (the file has to be in the same folder as compress.php)
    targetfilename->name of the compressed file (after compressing)

    b)At the top of the file decompress.php ,there would be two variables sourcefilename and targetfilename sourcefilename=>name of the file that would be decompressed (the file has to be in the same folder as decompress.php) targetfilename->name of the decompressed file (after decompressing)

    Mods:If this is not the right place move this thread to the correct one..
     

    Attached Files:

    Freewebspace, May 13, 2009 IP
  2. WeedGrinch

    WeedGrinch Active Member

    Messages:
    1,236
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    90
    #2
    /gasp

    That's really impressive =O
     
    WeedGrinch, May 13, 2009 IP
  3. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #3
    Some better than me would be able to come out with a better one using this Algorithm..I hope
     
    Freewebspace, May 13, 2009 IP
  4. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #4
    Why you are posting this here?
     
    buldozerceto, May 13, 2009 IP
  5. technolarity

    technolarity Well-Known Member

    Messages:
    1,582
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    115
    #5
    It didnt worked for me,,,
     
    technolarity, May 13, 2009 IP
  6. Stroh

    Stroh Notable Member

    Messages:
    3,482
    Likes Received:
    292
    Best Answers:
    0
    Trophy Points:
    200
    #6
    The easiest way is to just use 7zip.

    Impressive btw, I wouldn't think to split unless I looked at how Linux managed archives.
     
    Stroh, May 13, 2009 IP
  7. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #7
    Can you tell me what error you are getting??

    I am posting it here .. only to have some good review comments about it..
     
    Freewebspace, May 13, 2009 IP
  8. technolarity

    technolarity Well-Known Member

    Messages:
    1,582
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    115
    #8
    Something related to line 21

    What is the address of input file.. and output file to be provided?
     
    technolarity, May 14, 2009 IP
  9. manzoD15

    manzoD15 Guest

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Great. better explanation. Ive learned a lot from this.. thanks anyway.
     
    manzoD15, May 14, 2009 IP
  10. kmofo

    kmofo Active Member

    Messages:
    442
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    85
    #10
    Interesting. What you are really doing is relying on the PNG file compression that can be described as a generic lossless compression. This kind of compression is used by both zip and rar algorithms.

    Anyway I've done some tests and here are the results:
    1) TXT file, size: 63KB -----> your compression shrinks it down to 21KB;
    -----> RAR : 13KB.
    2) JPG file, size: 49K ------> your result: 46KB;
    ------> RAR: 43KB.

    Conclusion: It is a good, pretty fast technique to compress something whenever you don't have any other tools handy.
     
    kmofo, May 14, 2009 IP
  11. VBK

    VBK Peon

    Messages:
    429
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Good one.. It's better to find a technique to split characters into three and using combinations to convert it into an image. This can be used for compression and also to prevent data theft...

    Good idea....:)
     
    VBK, May 14, 2009 IP
  12. WeedGrinch

    WeedGrinch Active Member

    Messages:
    1,236
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    90
    #12

    When I try to use it with smaller files, it works fine. I tried using it to compress a song that was ~3 or 4 MB. it gave me this error:
    Warning: imagepng() [function.imagepng]: gd-png: fatal libpng error: image size exceeds user limits in IHDR in
    Code (markup):
    It's uploaded here
    http://gamingjunkiez.com/test/compress.php
    Code (markup):
     
    WeedGrinch, May 14, 2009 IP
  13. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #13
    WeedGrinch: I don't think you understand this is for 'text' files not binary files.

    OP: I would like to see one of these images that your compression has produced. Would be nice to see what each of the major documents in history looks like under your compression as a image. Never know something might turn out to be a 'pretty' image or could look like a jumbled mess of stuff.
     
    exodus, May 15, 2009 IP
  14. WeedGrinch

    WeedGrinch Active Member

    Messages:
    1,236
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    90
    #14
    .......

    :confused:?
     
    WeedGrinch, May 15, 2009 IP
  15. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #15
    I think it may be related with memory used by the scripts


    Image is of No of pixels x1 size. .(Image would be only a straight line but it can be converted to any dimensions day 1024x1024 depending upon the size)
     
    Freewebspace, May 16, 2009 IP
  16. jeewant_gupta_051275

    jeewant_gupta_051275 Well-Known Member

    Messages:
    800
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    108
    #16
    This technique is not new, I guess...its just called stenography in common terms..isn't it? Correct me if um wrong...
     
    jeewant_gupta_051275, May 16, 2009 IP
  17. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #17
    Stenography is otherwise known as shorthand writing?But where here shorthand is involved?
     
    Freewebspace, May 16, 2009 IP
  18. jeewant_gupta_051275

    jeewant_gupta_051275 Well-Known Member

    Messages:
    800
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    108
    #18
    Srry, I meant StegAnography, not stenography...Steganography refers to the practice of hiding info within pics etc such that its encrypted...what u did is quite similar to info hiding..
     
    jeewant_gupta_051275, May 16, 2009 IP
  19. Freewebspace

    Freewebspace Notable Member

    Messages:
    6,213
    Likes Received:
    370
    Best Answers:
    0
    Trophy Points:
    275
    #19
    That's all about hiding messages in a pictures of your choice

    http://mozaiq.org/encrypt/

    But here it's deals with compression of data and here picture created is not of your choice.It's is automatically created so it's entirely different from Steganography.
     
    Freewebspace, May 16, 2009 IP