Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > GRA. - Picture/Image Commands >

Image/Pixel-Color Operations

GRA. - Graphic Command: Scale

Previous Top Next


MiniRobotLanguage (MRL)

 

GRA.scale Command

Scale Image Size

 

 

Intention

 

GRA.scale  will resize an image, keeping the Aspect Ratio. For this the Original image will be copied to a new file with the same or with another file extension.

 

The following file-Types can be specified as Source or destination file:

 

BMP

EMF

JPG or JPEG

GIF

ICO

PNG

TIF or TIFF

WMF

 

The resolution in Y-direction will automatically be calculated in a way that the original Apect-Ratio is been preserved.

 

To convert a .BMP-Picture to .JPG you could write:

 

' This will create a File MyPic.JPG on the Desktop

' Because this is where the Source file also comes

' from.
$$FIL=?desktop\MyPic.BMP

GRA.sca|$$FIL|JPG|1024#

 

    Instead of just writing the new Filetype as Destination, you can give a complete Filename and/or path.

 

   GRA.sca|$$FIL|?desktop\MyFile.BMP

   ' The following two commands let you see the STACK content.

   DMP.6

   MBX.!

 

   
   Stack Usage / Return values:
 
    Any GRA.-Operation will leave several values on the stack, depending on the success of the Operation.

    Here is an Example:

 

GRA_Con

 

Here is an explanation of the stack values:

 

Position:      Explanation:

  0 (TOS)  Is 0 if the GRA.-Operation was successful. Any other value may indicate an error: 1 - Filename or Path Error. 2 - Parameter - Error.

  1        Path and Filename of the converted destination file.

  2        S:OK if all was fine or can be E:Error-Message if there was an Problem during the Operation. The following numbers specify the type of Error.

 

In case of an parameter error - or an unusable destination path - the stack will just look like this.

 

GRA Err

 

 

 

 

 

Syntax

 

GRA.sca|P1|P2[|P3][|P4]

GRA.scale|P1|P2[|P3][|P4]

 

 

Parameter Explanation

 

P1 - Source file.

 

P2  - Destination File Path this can be:
    a)complete path with Filename and extension
      GRA.sca|$$FIL|?desktop\MyFile.BMP|1280#
 
    b)just the extension of the new file like "JPG"

        GRA.scale|$$FIL|BMP

 

    c) Only a new Filename with Extension. In this case the Source-File Path is used for the destination file.

        GRA.sca|$$FIL|MyFile.BMP|1280#

 

    d) Omit the filetype. In this case ".jpg" is used as default.

      GRA.sca|$$FIL|?desktop\MyFile

        GRA.sca|$$LAC|MyFile

 

P3 - X-Resolution of new Image. Y-Resolution is automatically choosen

    using the Aspect-ratio of the Original Image.
    If parameter is omitted, Original Image Resolution is taken.

    Here you can specify the following 2 additional Parameters:

    # - This will allow to upscale pictures to a higher resolution. If omitted, the maximum resolution is the Original resolution.

    @ - This will force the Process to keep the original resolution of the Source file

 

P4 - (optional) JPG - Compression Quality from 1 to 100.

     If parameter is omitted, "75" is taken.

 

Example:
   ' Activate Up-Scaler

  GRA.sca|$$FIL|?desktop\MyFile.BMP|1280#

 

   ' Force Original resolution

  GRA.sca|$$FIL|?desktop\MyFile.BMP|@

 

 

See above which values are placed on the Stack during the Operation.

 

 

 

 

Example

 

' Dieses Beispielscript muß kompiliert werden.

' zieht man dann eine Grafikdatei auf die Verknüpfung der kompilierten EXE-Datei,

' dann wird dort wo die Grafikdatrei liegt ein Ordner "SMall" erstellt und in
' diesen Ordner wird eine verkleinerte Kopie der Grafikdatei gelegt.
'

'***********************************

' +++ SF_Drag Pic_Scaler.mrt +++

' Zweck:

' erstellt am: 16.04.2018

' von: Theo Gottwald

'========================

'#EXE:?path\

'#SPI:ForceWrite

'#ICS:5

'#MAN:ai

'

MRK.2

' Ziel X- Auflösung,

' Y-Auflösung wird intern anhand Aspekt-Ratio berechnet

VAR.$$RES=503

' Qualitätseinstellung (1-100)

VAR.$$QUA=85

 

VAR.$$SRP=$cmdexe$

'VAR\$$SRP=?path\Kepler.jpg

 

VBT.$$SRP|"

'MBX\Bilder-Ordner: $crlf$$$SRP

 

NEF.$$SRP

  GTO.enx

EIF.

 

GFT.c|$$SRP|$$PTH

VAR.$$DEP=$$PTH\Small

'MBX\$$DEP

MKD.$$DEP

'FEF\$$SRP|*.jpg|Doit|$$SRC

VAR.$$SRC=$$SRP

 

GSB.Doit

:enx

MBX.!

ENR.

 

:Doit

SBT.$$SRC|T:2 FS:14 MP: NC:

IVC.$$SRC=$$DEP|e

  GTO.over

EIF.

GFT.je|$$SRC|$$EXT|$$FIN

' Dateiformat beibehalten

VAR.$$DES=$$DEP\$$FIN.$$EXT

 

' Immer nach "Jpg" Konvertieren

VAR.$$DES=$$DEP\$$FIN.jpg

'MBX.$$SRC$crlf$$$DES$crlf$$$QUA$crlf$$$RES

STV.TOVCLEAR|$$DUM

GRA.sca|$$SRC|$$DES|$$RES|$$QUA

:over

RET.

 

 

Remarks

 

-

 

 

 

Limitations:

 

A Quadratic Image should be upscaled up to about 26000 Pixels X/Y-Size that is 676 MegPixel.
Larger sizes may work or fail, depending on the Memory Situation in Windows.

 

 

 

See also:

 

    1.8. Selecting the Application (Topwindow)

    IPC. / NPC. - If-Pixel-Colour

    GPC. - Get-Pixel-Colour