This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
PICTURE TO BLOB

PICTURE TO BLOB 


 

PICTURE TO BLOB ( picture ; pictureBlob ; codec ) 
Parameter Type   Description
picture  Picture in Picture field or variable
pictureBlob  BLOB in BLOB to receive the converted picture
codec  String in Picture Codec ID

The PICTURE TO BLOB command converts a picture stored in a 4D variable or field to another format and places the resulting picture in a BLOB.

A picture 4D field or variable is passed in the picture parameter. In the pictureBlob parameter is passed a BLOB variable or field which should contain the converted picture.

Pass in the codec parameter a string setting the conversion format.

A Codec can be an extension (for example, “.gif”) or a Mime type (for example “image/jpeg”). You can get a list of available Codecs via the PICTURE CODEC LIST command.

Once the command has been executed, the pictureBlob contains the picture in the specified format.

If the conversion was successful, the system variable OK is set to 1. If the conversion has failed (converter not available), OK is set to 0 and the generated BLOB is empty (0 byte).

Example  

You want to convert an image from a proprietary format to GIF format and display it on a static web page. You can use a code such as:

 C_PICTURE($picture)
 C_BLOB($BLOB)
 C_TEXT($path)
 
 $path:=Get 4D folder(Current resources folder)+"Images"+Folder separator+"Sunrise.psd" //find the picture in the Images folder within the Resources folder
 READ PICTURE FILE($path;$picture//put the picture in the picture variable
 
 PICTURE TO BLOB($picture;$BLOB;".gif") //convert the picture to ".gif" format
 WEB SEND BLOB($BLOB;"image/gif")



See also 

_o_PICTURE TO GIF
BLOB TO PICTURE
PICTURE CODEC LIST
WRITE PICTURE FILE

 
PROPERTIES 

Product: 4D
Theme: Pictures
Number: 692

The OK variable is changed by the commandThis command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Modified: 4D v11 SQL

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)