Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript compress base64 image

/*
Maybe string compression is the solution for you. 
This converts the data to byte arrays.

There are multiple implementations and algorithms around, for instance

LZMA-JS A standalone JavaScript implementation of the Lempel-Ziv-Markov chain (LZMA) compression algorithm.
*/
var str = "This is my compression test.";
console.log("Size of sample is: " + str.length);
var compressed = LZString.compress(str);
console.log("Size of compressed sample is: " + compressed.length);
str = LZString.decompress(compressed);
console.log("Sample is: " + str);
//solution 2
my_lzma = new LZMA("./lzma_worker.js");
my_lzma.compress("This is my compression test.", 1, function on_compress_complete(result) {
    console.log("Compressed: " + result);
    my_lzma.decompress(result, function on_decompress_complete(result) {
        console.log("Decompressed: " + result);
    }, function on_decompress_progress_update(percent) {
        console.log("Decompressing: " + (percent * 100) + "%");
    });
}, function on_compress_progress_update(percent) {
    console.log("Compressing: " + (percent * 100) + "%");
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: vuejs slots events 
Javascript :: how to convert string to pascal case in javascript 
Javascript :: the rest operator javascript 
Javascript :: javascript most frequent in a list 
Javascript :: rest parameters 
Javascript :: moment get difference between business dates 
Javascript :: bash sort json alphabetically 
Javascript :: remove shadow in jquery 
Javascript :: how to use moment to compare time for calendar change color 
Javascript :: how to set dynamic autocomplete with material ui 
Javascript :: foreach and replace item based on condition 
Javascript :: jquery select element inside element 
Javascript :: IntersectionObserver polyfill 
Javascript :: javascript true string to boolean 
Javascript :: json server start code 
Javascript :: a tag how to trigger ajax 
Javascript :: post object 
Javascript :: express and node pakages 
Javascript :: jquery creating several items 
Javascript :: {"statusCode":400,"error":"Bad Request","message":"Unexpected token o in JSON at position 1"} 
Javascript :: how to define width with [styles] in percentage in angular 
Javascript :: react proxy error: could not proxy request from localhost:3000 to http localhost:5000 econnreset 
Javascript :: find option values using javascript 
Javascript :: You are trying to create a styled element with an undefined component.You may have forgotten to import it. 
Javascript :: formdata 
Javascript :: radio button schema mongoose 
Javascript :: sequelize documentation 
Javascript :: javascript stringify blob 
Javascript :: hide and open jquery 
Javascript :: nestjs framwork 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =