Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   Crossplatform   Server (Not)   Client   Components   Old   Guides
New in version: 4.0   4.1   4.2   4.3   4.4   5.0   5.1   5.2   5.3   5.4   6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1    Statistic  

GMImage.Scale

Resize image by using simple ratio algorithm.

Component: GraphicsMagick
Version: 2.0
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "GMImage.Scale"; ImageRef; Geometry )

Parameters

Parameter Description Example value
ImageRef The image reference (a number returned from the GMImage.New functions) 1
Geometry The rectangle. Geometry is specified as a width and height "100x200". With an optional offset "100x200+10+20". For percent values, add a percent on the end, for % values add a %: "100x200%!" "300x200"

Result

Returns "OK" on success.

Description

Resize image by using simple ratio algorithm.

GraphicsMagick has added a number of qualifiers to the standard geometry string for use when resizing images. The form of an extended geometry string is "<width>x<height>{+-}<xoffset>{+-}<yoffset>{%}{!}{<}{>}". Extended geometry strings should only be used when resizing an image. Using an extended geometry string for other applications may cause the API call to fail. The available qualifiers are shown in the following table:

QualifierDescription
%Interpret width and height as a percentage of the current size.
!Resize to width and height exactly, loosing original aspect ratio.
<Resize only if the image is smaller than the geometry specification.
>Resize only if the image is greater than the geometry specification.

Examples

Scales the image to 50% with calculating ourself

Let ( [
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
$Width = MBS("GMImage.GetWidth";$Image);
$Height = MBS("GMImage.GetHeight";$Image);
$Width = $Width/2;
$Height = $Height/2;
$ScaleResult = MBS("GMImage.Scale";$Image; $Width & "x" & $Height);
$Result = MBS("GMImage.WriteToPNGContainer"; $Image);
$Error = MBS("GMImage.Destroy";$Image)
];
$Result)

Scales the image to 50% easily

Let ( [
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
$ScaleResult = MBS("GMImage.Scale";$Image; "50%");
$Result = MBS("GMImage.WriteToPNGContainer"; $Image);
$Error = MBS("GMImage.Destroy";$Image)
];
$Result)

Scales the image down to 640 pixel width, if it is bigger

Let ( [
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
$ScaleResult = MBS("GMImage.Scale";$Image; "640>");
$Result = MBS("GMImage.WriteToPNGContainer"; $Image);
$Error = MBS("GMImage.Destroy";$Image)
];
$Result)

Scale as script:

Set Variable [$Image; Value:MBS("GMImage.NewFromContainer"; Image Scaling::InputImage)]
Set Variable [$r; Value:MBS("GMImage.Scale"; $Image; "800x600")]
Set Field [Image Scaling::Result; MBS("GMImage.WriteToPNGContainer"; $Image)]
Set Variable [$r; Value: MBS("GMImage.Destroy"; $Image)]

See also


GMImage.Sample   -   GMImage.Scaling

Feedback: Report problem or ask question.




Links
MBS Realbasic Chart Plugins - Pfarrgemeinde St. Arnulf Nickenich