oid_write_graphic
oid_write_graphic (oid, path[, type[, attrmask[, quality[, cgmprofile]]]])
This function creates a graphic file based on the element identified by oid in the file format specified by type and writes the output file to the specified path. The attrmask parameter indicates how the graphic element should be scaled. The quality parameter can be used for JPEG graphics to better control the output file size balanced against output quality. The cgmprofile parameter can be used for CGM graphics to specify the CGM profile for the graphic.
A relative path is relative to the current working directory.
If oid refers to an intelligent graphic, the type can be eps, jpg, png, or cgm. If the type is set to cgm, the cgmprofile parameter can be used to specify the CGM profile for the graphic.
The settings of the reproDepth and reproWidth attributes on oid are used to create the graphic file. If none of these attributes are specified, the default values are used.
For graphics other than intelligent graphics, type can be "gif", "png", "jpg", or "jpeg". If type is omitted, the function will convert the element to GIF format.
attrmask can have the following values:
• 0 — Indicates the graphic should be scaled exactly as displayed in the Edit pane.
This is the default setting.
• 1 — Indicates the graphic should be scaled based on the screen resolution.
Any explicit scaling, such as that set in attribute values, is ignored for this setting.
If the graphic is an intelligent graphic, attrmask is ignored.
You can specify quality for a JPEG graphic. Set the value to a number from 1 to 100, where 1 is lowest quality and smallest file size and 100 is highest quality and largest file size. You may need to experiment with this setting for best results. The default is 80. If type is "gif" or "png" or if the graphic is an intelligent graphic, any value specified for quality is ignored.
You can specify the cgmprofile for a CGM graphic. If cgmprofile is not set, then the value of the set cgmprofile preference is used. If that preference is also not set, the WebCGM 2.0 profile is used. The following CGM profiles are supported:
• WebCGM_2.0
• WebCGM_1.0
• ISO_8632_:_1999
• ATA_GREXCHANGE_V2.10
• ATA_GREXCHANGE_V2.9
• ATA_GREXCHANGE_V2.8
• ATA_GREXCHANGE_V2.7
• ATA_GREXCHANGE_V2.6
• ATA_GREXCHANGE_V2.5
• ATA_GREXCHANGE_V2.4
• ATA_GREXCHANGE_V2.5/IsoDraw
• CALS_MIL-D-28003A
• SAE_J2008
• Model_Profile_(ISO_8632:1992/Am.1:1994)
• ISO_ISP_12071-1_(FCG11)_(Draft)
• ISO_ISP_12071-2_(FCG23)_(Draft)
• ISO_ISP_12071-3_(FCG32)_(Draft)
• ISO_ISP_12071-4_(FCG33)_(Draft)
• S1000D_V2.3
• S1000D_V2.2
This function returns
1 (True) if the conversion succeeds, and
0 (False) if it fails. If it fails, the function writes an error message to the $ERROR
predefined variable.
The following example converts every graphic and equation in a document to GIF format:
$g=0
$e=0
$o=oid_first()
while (oid_valid($o)) {
if (oid_is_graphic($o))
{
$gname = "c:\\temp\\graphic" .$g. ".gif"
oid_write_graphic($o,$gname)
$g = $g + 1
}
if (oid_type($o)== 4)
{
$ename = "c:\\temp\\equation" .$e. ".gif"
oid_write_graphic($o,$ename)
$e = $e + 1
}
$o = oid_forward($o)
}
Related Topics