4D v16.3

BLOB PROPERTIES

Home

 
4D v16.3
BLOB PROPERTIES

BLOB PROPERTIES 


 

BLOB PROPERTIES ( blob ; compressed {; expandedSize {; currentSize}} )  
Parameter Type   Description
blob  BLOB in BLOB for which to get information
compressed  Longint in 0 = BLOB is not compressed, 1 = Compact compression, 2 = Fast compression, -1 = GZIP Best compression, -2 = GZIP Fast compression
expandedSize  Longint in Size of BLOB (in bytes) when not compressed
currentSize  Longint in Current size of BLOB (in bytes)

The BLOB PROPERTIES command returns information about the BLOB blob.

The compressed parameter returns a value indicating if and how the BLOB is compressed. You can compare this value with the following constants, found in the BLOB theme:

Constant Type Value Comment
Compact compression mode Longint 1 Compressed as much as possible (at the expense of the speed of compression and decompression operations). Default method.
Fast compression mode Longint 2 Compressed as fast as possible (and will be decompressed as fast as possible), at the expense of the compression ratio (the compressed BLOB will be bigger).
GZIP best compression mode Longint -1 Most compact GZIP compression
GZIP fast compression mode Longint -2 Fastest GZIP compression
Is not compressed Longint 0 No compression

Whatever the compression status of the BLOB, the expandedSize parameter returns the size of the BLOB when it is not compressed.

The parameter currentSize returns the current size of the BLOB. If the BLOB is compressed, you will usually obtain currentSize less than expandedSize. If the BLOB is not compressed, you will always obtain currentSize equal to expandedSize.

See examples for the commands COMPRESS BLOB and EXPAND BLOB.

After a BLOB has been compressed, the following project method obtains the percentage of space saved by the compression:

  ` Space saved by compression project method
  ` Space saved by compression (Pointer {; Pointer } ) -> Long integer
  ` Space saved by compression ( -> BLOB {; -> savedBytes } ) -> Percentage
 
 C_POINTER($1;$2)
 C_LONGINT($0;$vlCompressed;$vlExpandedSize;$vlCurrentSize)
 
 BLOB PROPERTIES($1->;$vlCompressed;$vlExpandedSize;$vlCurrentSize)
 If($vlExpandedSize=0)
    $0:=0
    If(Count parameters>=2)
       $2->:=0
    End if
 Else
    $0:=100-(($vlCurrentSize/$vlExpandedSize)*100)
    If(Count parameters>=2)
       $2->:=$vlExpandedSize-$vlCurrentSize
    End if
 End if

After this method has been added to your application, you can use it this way:

  ` ...
 COMPRESS BLOB(vxBlob)
 $vlPercent:=Space saved by compression(->vxBlob;->vlBlobSize)
 ALERT("The compression saved "+String(vlBlobSize)+" bytes, so "+String($vlPercent;"#0%")+
 " of space.")



See also 

COMPRESS BLOB
EXPAND BLOB

 
PROPERTIES 

Product: 4D
Theme: BLOB
Number: 536

 
HISTORY 

Created: 4D v6
Modified: 4D v13

 
TAGS 

blob compression, Compression

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)