Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2   11.3   11.4    Statistic    FMM    Blog  

GMImage.SetResolutionUnits

Sets which units are used for image resolution.

Component Version macOS Windows Linux Server iOS SDK
GraphicsMagick 2.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "GMImage.SetResolutionUnits"; ImageRef; ResolutionType )   More

Parameters

Parameter Description Example
ImageRef The image reference number. 1
ResolutionType UndefinedResolution = 0, PixelsPerInchResolution = 1, PixelsPerCentimeterResolution = 2 1

Result

Returns "OK" on success.

Description

Sets which units are used for image resolution.

Examples

Convert and Scale:

# Load image from container
Set Variable [ $image ; Value: MBS( "GMImage.NewFromContainer"; SVG to PNG::InputFile ) ]
Set Variable [ $name ; Value: MBS( "Files.FileName"; LiesAlsText(SVG to PNG::InputFile) ) ]
# Scale if parameters are filled in fields
If [ IsEmpty ( SVG to PNG::Target Width in Pixel ) ]
    If [ IsEmpty ( SVG to PNG::Target Height in Pixel ) ]
        # both empty, do nothing
    Else
        Set Variable [ $r ; Value: MBS( "GMImage.Scale"; $image; "99999x" & SVG to PNG::Target Height in Pixel & ">") ]
    End If
Else
    If [ IsEmpty ( SVG to PNG::Target Height in Pixel ) ]
        Set Variable [ $r ; Value: MBS( "GMImage.Scale"; $image; SVG to PNG::Target Width in Pixel& ">" ) ]
    Else
        Set Variable [ $r ; Value: MBS( "GMImage.Scale"; // function $image; // pass in picture SVG to PNG::Target Width in Pixel & // width "x" & // by SVG to PNG::Target Height in Pixel & // height ">" // scale only if it will get smaller ) ]
    End If
End If
# If a resolution is defined, put it in
Wenn [ NOT IsEmpty ( SVG to PNG::Resolution in DPI ) ]
    Set Variable [ $r ; Value: MBS( "GMImage.SetResolutionUnits"; $image; 1 /* pixel per inch */ ) ]
    Set Variable [ $r ; Value: MBS( "GMImage.SetDensity"; $image; SVG to PNG::Resolution in DPI & "x" & SVG to PNG::Resolution in DPI) ]
End If
# Output to container
Set Field [ SVG to PNG::OutputFile ; MBS( "GMImage.WriteToPNGContainer"; $image; $name & ".png") ]
# Cleanup
Set Variable [ $r ; Value: MBS("GMImage.Release"; $image) ]

See also

Example Databases

Created 18th August 2014, last changed 16th December 2020


GMImage.SetRenderingIntent - GMImage.SetScene

Feedback: Report problem or ask question.