LZMA: The new compression algorithm

Whenever we exchange files, we always go through the ritual of compressing the files before sending them. Since 4D v18, two commands are available, allowing you to create and read a ZIP archive using the standard zip compression algorithm.

With 4D V19 R3, the Zip Create Archive command supports a new compression algorithm: LZMA. The advantage of this algorithm is that it creates smaller archives than the standard zip compression algorithm. Let’s find out more!

What Is LZMA?

LZMA is the acronym for Lempel-Ziv-Markov chain algorithm. LMZA is a lossless compression algorithm created by Igor Pavlov. This data compression algorithm uses a dictionary compression scheme similar to the LZ77 algorithm published by Abraham Lempel and Jacob Ziv.

How to use it?

You can pass a “zipArchive” object to the ZIP Create Archive command to customize your zip. This allows you to choose the compression algorithm, the encryption algorithm, and some other options. Read the documentation for more details.

For the compression algorithm, you can set the “compression” attribute to:

  • ZIP Compression None
  • ZIP Compression Standard
  • ZIP Compression LZMA
  • ZIP Compression XZ

 

For the compression level, you can set the “level” attribute between 1 to 10.

Here is an example that compresses a folder using the LZMA algorithm:

var $zip; $status : Object
var $destination : 4D.File
$zip:=New object
$zip.files:=New collection
$zip.files.push(Folder(fk documents folder).folder("Archive 2020"))
$zip.compression:=ZIP Compression LZMA
$zip.level:=4
$destination:=Folder(fk desktop folder).file("Archive2020.zip")
$status:=ZIP Create archive($zip; $destination)

Here is the result obtained on an archive of almost 2GB containing 1800 images:

Back to you! Do not hesitate to share your feedback and impressions on the forum.

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.