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

MBS FileMaker Plugin Example Databases

Trim Picture

All examples are included with download of MBS FileMaker Plugin.

Trim Picture.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts3
Value Lists1
Custom Functions0
Custom Menus32
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
Test
2 fields defined, 1 record
Test

Fields

Table Name: Test - 2 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
BigImageNormal, BinaryAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
      ResultNormal, BinaryAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1

          Layout Objects: Test

          Regular Fields

          Field Name: Test::BigImage
          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
          • Top: 109 pt
          • Left: 6 pt
          • Bottom: 587 pt
          • Right: 367 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: Test::Result
          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
          • Top: 109 pt
          • Left: 372 pt
          • Bottom: 587 pt
          • Right: 733 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

          Buttons

          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: Trim whitespace
          • Top: 594 pt
          • Left: 624 pt
          • Bottom: 626 pt
          • Right: 733 pt
          • Anchoring: Left, Top
          Perform Script [ “TrimPictures” ]

          Scripts:


          Value Lists

          Value List NameSourceValuesOn Layouts
          CompositeOpCustom
          • 0 = UndefinedCompositeOp, 1 = OverCompositeOp, 2 = InCompositeOp, 3 = OutCompositeOp, 4 = AtopCompositeOp, 5 = XorCompositeOp, 6 = PlusCompositeOp, 7 = MinusCompositeOp, 8 = AddCompositeOp, 9 = SubtractCompositeOp, 10 = DifferenceCompositeOp, 11 = MultiplyCompositeOp, 12 = BumpmapCompositeOp, 13 = CopyCompositeOp, 14 = CopyRedCompositeOp, 15 = CopyGreenCompositeOp, 16 = CopyBlueCompositeOp, 17 = CopyOpacityCompositeOp, 18 = ClearCompositeOp, 19 = DissolveCompositeOp, 20 = DisplaceCompositeOp, 21 = ModulateCompositeOp, 22 = ThresholdCompositeOp, 23 = NoCompositeOp, 24 = DarkenCompositeOp, 25 = LightenCompositeOp, 26 = HueCompositeOp, 27 = SaturateCompositeOp, 28 = ColorizeCompositeOp, 29 = LuminizeCompositeOp, 32 = CopyCyanCompositeOp, 33 = CopyMagentaCompositeOp, 34 = CopyYellowCompositeOp, 35 = CopyBlackCompositeOp, 36 = DivideCompositeOp

            Script Hierarchy

            TrimPictures
            Remove Alpha Channel
            TrimPictures extended

            Next Script: [Remove Alpha Channel]
            Script NameTrimPictures
            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
              • #Set the background color and trimm the picture to a rectangle
              • #Load from container
              • Set Variable [ $BigImageRef; Value:MBS("GMImage.NewFromContainer"; Test::BigImage) ]
              • // Set Variable [ $Result; Value:MBS( "GMImage.SetBackgroundColor"; $BigImageRef; "RGB 1 0 0" ) ]
              • #Trim looks on what pixel colors the edges have and checks if there is a smaller rectangle where all pixel outside have same color. Then it cut out this rectangle.
              • Set Variable [ $Result; Value:MBS("GMImage.Trim"; $BigImageRef) ]
              • #Store output and release the image
              • Set Field [ Test::Result; MBS( "GMImage.WriteToJPEGContainer"; $BigImageRef ) ]
              • Set Variable [ $Error; Value:MBS("GMImage.Free";$BigImageRef) ]
              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: [TrimPictures]Next Script: [TrimPictures extended]
                      Script NameRemove Alpha Channel
                      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
                          • #Remove alpha channel
                          • #Load from container
                          • Set Variable [ $BigImageRef; Value:MBS("GMImage.NewFromContainer"; Test::BigImage) ]
                          • #set the color to use for transparent areas
                          • Set Variable [ $Result; Value:MBS("GMImage.SetBackgroundColor"; $BigImageRef; "white") ]
                          • #and remove transparency
                          • Set Variable [ $Result; Value:MBS("GMImage.Flatten"; $BigImageRef) ]
                          • #Store output and release the image
                          • Set Field [ Test::Result; MBS( "GMImage.WriteToJPEGContainer"; $BigImageRef ) ]
                          • Set Variable [ $Error; Value:MBS("GMImage.Free";$BigImageRef) ]
                          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: [Remove Alpha Channel]
                                  Script NameTrimPictures extended
                                  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
                                      • #Trim the image and replace the backgoundcolor with transparancy
                                      • #Load from container
                                      • Set Variable [ $BigImageRef; Value:MBS("GMImage.NewFromContainer"; Test::BigImage) ]
                                      • #Set the background color
                                      • Set Variable [ $r; Value:MBS( "GMImage.SetColorFuzz"; $BigImageRef; 5 ) ]
                                      • #Trim looks on what pixel colors the edges have and checks if there is a smaller rectangle where all pixel outside have same color. Then it cut out this rectangle.
                                      • Set Variable [ $r; Value:MBS("GMImage.Trim"; $BigImageRef) ]
                                      • #Set that image support transparency
                                      • Set Variable [ $r; Value:MBS( "GMImage.SetMatte"; $BigImageRef; 1 ) ]
                                      • #Get the background color and replace the color with transparancy
                                      • Set Variable [ $color; Value:MBS( "GMImage.GetPixelColor"; $BigImageRef; 0; 0 ) ]
                                      • Set Variable [ $r; Value:MBS( "GMImage.ReplaceColor"; $BigImageRef; $color; "RGB 1 1 1 1"; 5) ]
                                      • #Store output and release the image
                                      • Set Field [ Test::Result; MBS( "GMImage.WriteToPNGContainer"; $BigImageRef ) ]
                                      • Set Variable [ $r; Value:MBS("GMImage.Free";$BigImageRef) ]
                                      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: Trim Picture

                                              Used functions: