Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

Image Scaling

All examples are included with download of MBS FileMaker Plugin.

Image Scaling.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts3
Value Lists0
Custom Functions0
Custom Menus24
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Image Scaling
6 fields defined, 7 records
Image Scaling

Fields

Table Name: Image Scaling - 6 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
InputImageNormal, BinaryAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Global
  • Repetitions: 1
      SizeNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          ResultNormal, BinaryAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
              CommentNormal, TextAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                    InfoNormal, TextAuto-Enter:
                    • Allow editing
                    Validation:
                    • Only during data entry
                    Storage:
                    • Repetitions: 1
                    • Indexing: None
                    • Automatically create indexes as needed
                    • Index Language: German
                        Container SizeNormal, NumberAuto-Enter: Validation:
                        • Only during data entry
                        Storage:
                        • Repetitions: 1
                        • Indexing: None
                        • Automatically create indexes as needed
                        • Index Language: German

                              Layout Objects: Image Scaling

                              Regular Fields

                              Field Name: Image Scaling::InputImage
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 125 pt
                              • Left: 139 pt
                              • Bottom: 418 pt
                              • Right: 554 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              No

                              Field Name: Image Scaling::Size
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 455 pt
                              • Left: 139 pt
                              • Bottom: 476 pt
                              • Right: 392 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              Yes

                              Field Name: Image Scaling::Result
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 483 pt
                              • Left: 139 pt
                              • Bottom: 788 pt
                              • Right: 554 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              No

                              Field Name: Image Scaling::Comment
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 455 pt
                              • Left: 505 pt
                              • Bottom: 476 pt
                              • Right: 758 pt
                              • Anchoring: Left and Right, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              Yes

                              Field Name: Image Scaling::Info
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 721 pt
                              • Left: 571 pt
                              • Bottom: 742 pt
                              • Right: 758 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              Yes

                              Field Name: Image Scaling::Container Size
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 767 pt
                              • Left: 571 pt
                              • Bottom: 788 pt
                              • Right: 758 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: Default for Data Type
                              • Go to next field using: Tab key
                              Yes

                              Buttons

                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Clear Images
                              • Top: 263 pt
                              • Left: 571 pt
                              • Bottom: 293 pt
                              • Right: 692 pt
                              • Anchoring: Left, Top
                              Perform Script [ “ClearImages” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Scale Image
                              • Top: 483 pt
                              • Left: 571 pt
                              • Bottom: 513 pt
                              • Right: 692 pt
                              • Anchoring: Left, Top
                              Perform Script [ “Scale” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Export Image
                              • Top: 524 pt
                              • Left: 571 pt
                              • Bottom: 554 pt
                              • Right: 692 pt
                              • Anchoring: Left, Top
                              Export Field Contents [ Image Scaling::Result; Create folders:No ]

                              Fields:


                              Script Hierarchy

                              Scale
                              ClearImages
                              Scale and save

                              Next Script: [ClearImages]
                              Script NameScale
                              Run script with full access privilegesOff
                              Siri Shortcut VisibleOff
                              Include In MenuYes
                              Layouts that use this script
                              Scripts that use this script
                                Script Definition
                                Script Steps
                                • #Scale the picture by given size
                                • #Load from container
                                • Set Variable [ $Image; Value:MBS("GMImage.NewFromContainer"; Image Scaling::InputImage) ]
                                • #Scale the image by the size that we enter in the size field
                                • Set Variable [ $r; Value:MBS("GMImage.Scale"; $Image; Image Scaling::Size) ]
                                • #In case of error
                                • If [ $r ≠ "OK" ]
                                • Show Custom Dialog [ Title: "Error"; Message: $r; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                • Set Field [ Image Scaling::Info; $r ]
                                • Exit Script [ ]
                                • Else
                                • #Write image to container and set the Information text
                                • Set Field [ Image Scaling::Result; MBS("GMImage.WriteToPNGContainer"; $Image) ]
                                • Set Field [ Image Scaling::Info; MBS("GMImage.GetWidth";$Image) & " x " & MBS("GMImage.GetHeight";$Image) ]
                                • End If
                                • #Release image
                                • Set Variable [ $r; Value: MBS("GMImage.Free";$Image) ]
                                Fields used in this script
                                Scripts used in this script
                                  Layouts used in this script
                                    Tables used in this script
                                    Table occurrences used by this script
                                    Custom Functions used by this script
                                      Custom menu set used by this script

                                        Previous Script: [Scale]Next Script: [Scale and save]
                                        Script NameClearImages
                                        Run script with full access privilegesOff
                                        Siri Shortcut VisibleOff
                                        Include In MenuYes
                                        Layouts that use this script
                                        Scripts that use this script
                                          Script Definition
                                          Script Steps
                                          • #Clear the image fields
                                          • Go to Record/Request/Page [ First ]
                                          • Loop [ Flush: Always ]
                                          • Set Field [ Image Scaling::Result; "" ]
                                          • Commit Records/Requests
                                          • Go to Record/Request/Page [ Next; Exit after last ]
                                          • End Loop
                                          Fields used in this script
                                          Scripts used in this script
                                            Layouts used in this script
                                              Tables used in this script
                                              Table occurrences used by this script
                                              Custom Functions used by this script
                                                Custom menu set used by this script

                                                  Previous Script: [ClearImages]
                                                  Script NameScale and save
                                                  Run script with full access privilegesOff
                                                  Siri Shortcut VisibleOff
                                                  Include In MenuYes
                                                  Layouts that use this script
                                                    Scripts that use this script
                                                      Script Definition
                                                      Script Steps
                                                      • #Scale the picture by given size
                                                      • #Load from container
                                                      • Set Variable [ $Image; Value:MBS("GMImage.NewFromContainer"; Image Scaling::InputImage) ]
                                                      • #Scale down to maximum 2000 by 2000 pixels
                                                      • Set Variable [ $r; Value:MBS("GMImage.Scale"; $Image; ">2000x2000") ]
                                                      • Set Variable [ $r; Value:MBS("GMImage.SetQuality"; $Image; 90) ]
                                                      • #In case of error
                                                      • If [ $r ≠ "OK" ]
                                                      • Show Custom Dialog [ Title: "Failed to load image"; Message: $r; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                      • Set Field [ Image Scaling::Info; $r ]
                                                      • Exit Script [ ]
                                                      • Else
                                                      • #For images with alpha channel, we use PNG, otherwise JPEG
                                                      • If [ MBS( "GMImage.GetMatte"; $Image ) ]
                                                      • Set Field [ Image Scaling::Result; MBS("GMImage.WriteToPNGContainer"; $Image) ]
                                                      • Else
                                                      • Set Field [ Image Scaling::Result; MBS("GMImage.WriteToJPEGContainer"; $Image) ]
                                                      • #let's check size
                                                      • Set Variable [ $size; Value:MBS("Container.GetTotalSize"; Image Scaling::Result) ]
                                                      • If [ $size > 1000000 // over 1 MB ]
                                                      • #try again with 80% quality
                                                      • Set Variable [ $size; Value:MBS("GMImage.SetQuality"; $Image; 80) ]
                                                      • Set Field [ Image Scaling::Result; MBS("GMImage.WriteToJPEGContainer"; $Image) ]
                                                      • End If
                                                      • End If
                                                      • Set Field [ Image Scaling::Info; MBS("GMImage.GetWidth";$Image) & " x " & MBS("GMImage.GetHeight";$Image) ]
                                                      • End If
                                                      • #Release image
                                                      • Set Variable [ $r; Value:MBS("GMImage.Release";$Image) ]
                                                      Fields used in this script
                                                      Scripts used in this script
                                                        Layouts used in this script
                                                          Tables used in this script
                                                          Table occurrences used by this script
                                                          Custom Functions used by this script
                                                            Custom menu set used by this script

                                                              Download example: Image Scaling

                                                              Used functions: