Module: MovingImages::CommandModule

Defined in:
lib/moving_images/smigcommands.rb

Overview

The command module. Houston, all your commands are belong to us.
All the module methods, and these all begin with "make_" create command objects. The created commands can be added to the list of commands or can be performed immediately by calling Smig.perform_command(...) with the command as the argument.

Defined Under Namespace

Classes: Command, DrawElementCommand, ObjectCommand, ProcessFramesCommand, RenderFilterChainCommand, SmigCommands

Class Method Summary (collapse)

Class Method Details

+ (ObjectCommand) make_addaudioinstruction(receiver_object, audioinstruction: nil)

Add a movie audio volume instruction.
Handled by a movie editor object.

Parameters:

  • receiver_object (Hash)

    Object that will handle the command.

  • audioinstruction (Hash, #audioinstructionhash)

    Audio volume instruction. See MIMovie::AudioInstruction

Returns:

  • (ObjectCommand)

    The made add audio volume setting instruction command



973
974
975
976
977
978
979
980
981
982
983
984
985
986
# File 'lib/moving_images/smigcommands.rb', line 973

def self.make_addaudioinstruction(receiver_object, audioinstruction: nil)
  theCommand = ObjectCommand.new(:addaudiomixinstruction, receiver_object)
  
  unless audioinstruction.nil?
    if audioinstruction.respond_to?("audioinstructionhash")
      audioinstruction = audioinstruction.audioinstructionhash
    end
    
    audioinstruction.each do |hashkey, hashvalue|
      theCommand.add_option(key: hashkey, value: hashvalue)
    end
  end
  theCommand
end

+ (ObjectCommand) make_addimage(receiver_object, image_source, imageindex: nil, grabmetadata: nil)

Make a addimage command
The image can be sourced from an image importer object, if so you can optionally supply an image index and assign the grabmetadata attribute with a value of true if you want to copy the original images metadata to be included with the added image when the image file is saved. If the image is sourced from any of the contexts (bitmap, window) then both the image index and grab metadata options will be ignored if specified. Handled by the image exporter object.

Parameters:

  • receiver_object (Hash)

    Object that will handle add image command

  • image_source (Hash)

    Object from which to get the image.

  • imageindex (Fixnum)

    the image index into source object to get image

  • grabmetadata (true, false)

    Default:false. Copy metadata from source

Returns:



1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
# File 'lib/moving_images/smigcommands.rb', line 1043

def self.make_addimage(receiver_object, image_source, imageindex: nil,
                       grabmetadata: nil)
  theCommand = ObjectCommand.new(:addimage, receiver_object)
  theCommand.add_option(key: :sourceobject, value: image_source)
  unless .nil?
    theCommand.add_option(key: :grabmetadata, value: )
  end

  unless imageindex.nil?
    options = { imageindex: imageindex }
    theCommand.add_option(key: :imageoptions, value: options)
  end
  
  theCommand
end

+ (ObjectCommand) make_addimage_fromimagecollection(receiver_object, imageidentifier: nil)

Make a add image command that takes the image from the image collection
The add image command is handled by the image exporter. The image is sourced from the image collection using the imageidentifier key to select the image in the collection. The image is added to the list of images in the image exporter object ready for export.

Parameters:

  • receiver_object (Hash)

    Object that will handle add image command

  • imageidentifier (String)

    The image identifier.

Returns:



1093
1094
1095
1096
1097
1098
1099
1100
# File 'lib/moving_images/smigcommands.rb', line 1093

def self.make_addimage_fromimagecollection(receiver_object, 
                          imageidentifier: nil)
  theCommand = ObjectCommand.new(:addimage, receiver_object)
  unless imageidentifier.nil?
    theCommand.add_option(key: :imageidentifier, value: imageidentifier)
  end
  theCommand
end

+ (ObjectCommand) make_addimage_frommovie(receiver_object, movie_object, frametime: nil, tracks: nil)

Make a addimage command that gets the image from a movie object
The add image command is handled by the image exporter. The image is sourced from a movie object. To get the image the time in the movie of the desired frame is required. You can also optionally specify the tracks from which to generate the image. If no tracks are are specified then the image generated is the movie frame at that time.

Parameters:

  • receiver_object (Hash)

    Object that will handle add image command

  • movie_object (Hash)

    Movie object from which to get the image.

  • frametime (Hash)

    A time representation. Either a CMTime rep or a time value representing time in seconds from start of the movie.

  • tracks (Array)

    Optional list of tracks to build image from.

Returns:



1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
# File 'lib/moving_images/smigcommands.rb', line 1071

def self.make_addimage_frommovie(receiver_object, movie_object,
                                    frametime: nil,
                                       tracks: nil)
  fail "No frame time is specified." if frametime.nil?
  theCommand = ObjectCommand.new(:addimage, receiver_object)
  theCommand.add_option(key: :sourceobject, value: movie_object)

  options = { frametime: frametime }
  options[:tracks] = tracks unless tracks.nil?
  theCommand.add_option(key: :imageoptions, value: options)

  theCommand
end

+ (ObjectCommand) make_addimageto_videoinputwriter(receiver_object, imageoptions: nil, imagecollectionidentifier: nil, sourceobject: nil, lastaccessedframedurationkey: nil, frameduration: nil)

Add an image as a video frame to the input of the video input writer.
Handled by a video frames writer object. One of imagecollectionidentifier and sourceobject need to be defined. If neither lastaccessedframedurationkey or frameduration are specified then the frame duration used is that provided when the video input was added to the writer. If both are specified then frameduration will be ignored.

Parameters:

  • receiver_object (Hash)

    Video frame writer object that adds the image

  • imageoptions (Hash)

    Optional. Options for obtaining object. An image importer might have an image index, a movie importer requires a frame time from which to obtain the image.

  • imagecollectionidentifier (String)

    Optional. Used as the key to get the image from the image collection.

  • sourceobject (Hash)

    Optional. Used to identify the object from which to obtain the image.

  • lastaccessedframedurationkey (String, Symbol)

    Optional. Only to be used within the process frames command of the movie importer. This is the key to pull from the variables dictionary the frame duration of the last image frame obtained from the image importer which will then be assigned as the frame duration of the image frame to be added.

  • frameduration (Hash)

    Optional. See MIMovie::MovieTime. The frame duration to be assigned to the image frame added.

Returns:



786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
# File 'lib/moving_images/smigcommands.rb', line 786

def self.make_addimageto_videoinputwriter(receiver_object,
                                             imageoptions: nil,
                                imagecollectionidentifier: nil,
                                             sourceobject: nil,
                             lastaccessedframedurationkey: nil,
                                            frameduration: nil)
  if imagecollectionidentifier.nil? && sourceobject.nil?
    fail "Missing one of image identifier or source object"
  end

  theCommand = ObjectCommand.new(:addimagesampletowriter, receiver_object)
  unless imageoptions.nil?
    if imageoptions.respond_to?('optionshash')
      imageoptions = imageoptions.optionshash
    end
    theCommand.add_option(key: :imageoptions, value: imageoptions)
  end
  
  unless imagecollectionidentifier.nil?
    theCommand.add_option(key: :imageidentifier,
                        value: imagecollectionidentifier)
  end
  
  unless lastaccessedframedurationkey.nil?
    theCommand.add_option(key: :lastaccessedframedurationkey,
                        value: lastaccessedframedurationkey)
  end
  
  unless frameduration.nil?
    theCommand.add_option(key: :frameduration,
                        value: frameduration)
  end
  
  unless sourceobject.nil?
    theCommand.add_option(key: :sourceobject,
                        value: sourceobject)
  end
  theCommand
end

+ (ObjectCommand) make_addinputto_videowritercommand(receiver_object, preset: :h264preset_hd, framesize: nil, frameduration: nil, cleanaperture: nil, scalingmode: nil)

Add a video input to the video frames writer object command
Handled by a video frames writer object.

Parameters:

  • receiver_object (Hash)

    Video writer object to add the input to.

  • preset (String, Symbol)

    Required. Video input preset. Possible values: h264preset_sd jpegpreset h264preset_hd prores4444preset prores422preset

  • framesize (Hash)

    Required. Size dict defining the video dimensions.

  • frameduration (Hash)

    Required. See MIMovie::MovieTime The expected frame duration time.

  • cleanaperture (Hash)

    Optional. A clean aperture rectangle using the aperture keys: AVVideoCleanApertureWidthKey, AVVideoCleanApertureHeightKey AVVideoCleanApertureHorizontalOffsetKey, AVVideoCleanApertureVerticalOffsetKey The value for these keys is numbers that specify the area within the video which must be shown when the video is displayed.

  • scalingmode (String, Symbol)

    Optional. The scaling mode to be used when the movie is to be watched. Possible values are: AVVideoScalingModeFit, AVVideoScalingModeResize, AVVideoScalingModeResizeAspect, AVVideoScalingModeResizeAspectFill

Returns:



744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/moving_images/smigcommands.rb', line 744

def self.make_addinputto_videowritercommand(receiver_object,
                                        preset: :h264preset_hd,
                                     framesize: nil,
                                 frameduration: nil,
                                 cleanaperture: nil,
                                   scalingmode: nil)
  theCommand = ObjectCommand.new(:addinputtowriter, receiver_object)
  theCommand.add_option(key: :preset, value: preset)
  theCommand.add_option(key: :size, value: framesize)
  theCommand.add_option(key: :frameduration, value: frameduration)
  unless cleanaperture.nil?
    theCommand.add_option(key: :AVVideoCleanApertureKey, value: cleanaperture)
  end
  
  unless scalingmode.nil?
    theCommand.add_option(key: :AVVideoScalingModeKey, value: scalingmode)
  end
  theCommand
end

+ (ObjectCommand) make_addvideoinstruction(receiver_object, timerange: nil, layerinstructions: nil)

Add a movie video composition instruction.
Handled by a movie editor object.

Parameters:

Returns:

  • (ObjectCommand)

    The made add video composition instruction command



949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
# File 'lib/moving_images/smigcommands.rb', line 949

def self.make_addvideoinstruction(receiver_object,
                       timerange: nil,
               layerinstructions: nil)
  theCommand = ObjectCommand.new(:addmovieinstruction, receiver_object)
  
  unless timerange.nil?
    theCommand.add_option(key: :timerange, value: timerange)
  end
  
  unless layerinstructions.nil?
    if layerinstructions.respond_to?("layerinstructionsarray")
      layerinstructions = layerinstructions.layerinstructionsarray
    end
    theCommand.add_option(key: :layerinstructions, value: layerinstructions)
  end
  theCommand
end

+ (ObjectCommand) make_assignimage_fromimporter_tocollection(receiver_object, imageindex: nil, identifier: nil)

Assign an imported image to the image collection.

Parameters:

  • receiver_object (Hash)

    File importer object that handles assign command

  • imageindex (Fixum)

    Optional. The image index defaults to 0.

  • identifier (String)

    The string to identify the image in collection

Returns:



1129
1130
1131
1132
1133
1134
1135
1136
1137
# File 'lib/moving_images/smigcommands.rb', line 1129

def self.make_assignimage_fromimporter_tocollection(receiver_object,
                                            imageindex: nil,
                                            identifier: nil)
  imageOptions = nil
  imageOptions = { imageindex: imageindex } unless imageindex.nil?
  return self.make_assignimage_tocollection(receiver_object,
                                      image_creation_options: imageOptions,
                                                  identifier: identifier)
end

+ (ObjectCommand) make_assignimage_frommovie_tocollection(receiver_object, frametime: nil, tracks: nil, identifier: nil)

Assign an movie frame image to the image collection.
If the tracks param is nil then the image is generated as if the movie is being rendered for display, which is typically rendering of all video tracks. Otherwise the image is generated from the compositing of the tracks in the tracks array.

Parameters:

  • receiver_object (Hash)

    Movie importer object that handles assign command

  • frametime (Hash)

    The movie time that specifies when to get frame.

  • tracks (Array)

    Optional. List of tracks to composite to create image.

  • identifier (String)

    The string to identify the image in collection

Returns:



1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
# File 'lib/moving_images/smigcommands.rb', line 1149

def self.make_assignimage_frommovie_tocollection(receiver_object,
                                                             frametime: nil,
                                                                tracks: nil,
                                                            identifier: nil)
  fail "Frame time to get movie frame from not specified. " if frametime.nil?
  imageOptions = { frametime: frametime }
  imageOptions[:tracks] = tracks unless tracks.nil?
  return self.make_assignimage_tocollection(receiver_object,
                                      image_creation_options: imageOptions,
                                                  identifier: identifier)
end

+ (ObjectCommand) make_assignimage_tocollection(receiver_object, image_creation_options: nil, identifier: nil)

Assign an image to the image collection.
The bitmap and window contexts, the movie and image file importer objects can all add images to the image collection. The importer objects take image_creation_options for creating the image to be added to the collection. If this command is sent to the movie editor object then the image added to the image collection is a map of the movie editor composition.

Parameters:

  • receiver_object (Hash)

    Object that is to add the image to collection

  • image_creation_options (Hash)

    Options for creating image

  • identifier (String)

    The string to identify the image in collection

Returns:



1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
# File 'lib/moving_images/smigcommands.rb', line 1112

def self.make_assignimage_tocollection(receiver_object,
               image_creation_options: nil,
                           identifier: nil)
  fail "Image collection identifier not specified. " if identifier.nil?
  theCommand = ObjectCommand.new(:assignimagetocollection, receiver_object)
  unless image_creation_options.nil? 
    theCommand.add_option(key: :imageoptions, value: image_creation_options)
  end
  theCommand.add_option(key: :imageidentifier, value: identifier)
  theCommand
end

+ (Command) make_calculategraphicsizeoftext(text: "How long is a piece of string", postscriptfontname: nil, userinterfacefont: nil, fontsize: nil)

Make a calculate the graphic size of text command.
The minimum needed for this command to function is the text and user interface font to be specified. Alternate to specifying the user interface font, you can specify the postscript font name and a font size as well as the text. If using the user interface font you can override its built in font size by specifying the font size.

Parameters:

  • text (String)

    The text to be measured how much space it takes

  • postscriptfontname (String, Symbol, nil)

    The post script font name

  • userinterfacefont (String, Symbol, nil)

    User interface name font name

  • fontsize (Fixnum, Float, nil)

    The font size.

Returns:

  • (Command)

    The calculate graphic size of text command



515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/moving_images/smigcommands.rb', line 515

def self.make_calculategraphicsizeoftext(
                                     text: "How long is a piece of string",
                                     postscriptfontname: nil,
                                     userinterfacefont: nil,
                                     fontsize: nil)
  theCommand = Command.new(:calculategraphicsizeoftext)
  theCommand.add_option(key: :objecttype, value: :bitmapcontext)
  theCommand.add_option(key: :getdatatype, value: :dictionaryobject)
  dict = { :stringtext => text }
  unless postscriptfontname.nil?
    dict[:postscriptfontname] = postscriptfontname
  end

  unless userinterfacefont.nil?
    dict[:userinterfacefont] = userinterfacefont
  end

      
  unless fontsize.nil?
    dict[:fontsize] = fontsize
  end

  theCommand.add_option(key: :saveresultstype, value: :jsonstring)
  theCommand.add_option(key: :inputdata, value: dict)
  theCommand
end

+ (ObjectCommand) make_cancelwritingframescommand(receiver_object)

Make a cancel writing frames command
If you need to stop the movie file being written and the file to be deleted then sending the cancel writing command will do that.

Returns:

  • (ObjectCommand)

    The constructed cancel writing frames command.



840
841
842
843
# File 'lib/moving_images/smigcommands.rb', line 840

def self.make_cancelwritingframescommand(receiver_object)
  theCommand = ObjectCommand.new(:cancelwritingframes, receiver_object)
  theCommand
end

+ (ObjectCommand) make_close(receiver_object)

Make a close object command

Parameters:

  • receiver_object (Hash)

    Object to handle the close command

Returns:



1180
1181
1182
1183
1184
# File 'lib/moving_images/smigcommands.rb', line 1180

def self.make_close(receiver_object)
  fail "receiver_object not of type hash" unless receiver_object.is_a? Hash
  theCommand = ObjectCommand.new(:close, receiver_object)
  theCommand
end

+ (ObjectCommand) make_copymetadata(receiver_object, importersource: nil, importerimageindex: 0, imageindex: 0)

Make a copy metadata command.
Copy metadata from an image importer for an image at index to the image in the exporter receiver object.

Parameters:

  • receiver_object (Hash)

    The object to set the property of

  • importersource (Hash)

    The image importer object

  • importerimageindex (Fixnum)

    The image index in the image importer

  • imageindex (Fixnum)

    The exporter image index to receive metadata

Returns:



669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/moving_images/smigcommands.rb', line 669

def self.(receiver_object, importersource: nil, 
                            importerimageindex: 0, imageindex: 0)
  theCommand = ObjectCommand.new(:setproperties, receiver_object)
  unless imageindex.nil?
    theCommand.add_option(key: :imageindex, value: imageindex)
  end
  unless importersource.nil?
    theCommand.add_option(key: :sourceobject, value: importersource)
  end
  unless importerimageindex.nil?
    theCommand.add_option(key: :secondaryimageindex,
                          value: importerimageindex)
  end
  theCommand
end

+ (Command) make_createbitmapcontext(width: 800, height: 600, size: nil, preset: :AlphaPreMulFirstRGB8bpcInt, profile: nil, name: nil)

Make a create bitmap context command
The color profile must match the color space, rgb profiles for a rgb color space, and a grayscale profile for a grayscale color space. The default rgb profile name is: kCGColorSpaceSRGB and a common alternative is: kCGColorSpaceGenericRGB

Parameters:

  • width (Fixnum, Float)

    The width of the bitmap context to be created

  • height (Fixnum, Float)

    Height of the bitmap context to be created.

  • size (Hash)

    A size hash. Size of bitmap. See MICGDrawing::MIShapes.make_size

  • preset (String, Symbol)

    Preset used to create the bitmap context. AlphaOnly8bpcInt Gray8bpcInt Gray16bpcInt Gray32bpcFloat AlphaSkipFirstRGB8bpcInt AlphaSkipLastRGB8bpcInt AlphaPreMulFirstRGB8bpcInt AlphaPreMulLastRGB8bpcInt AlphaPreMulLastRGB16bpcInt AlphaSkipLastRGB16bpcInt AlphaSkipLastRGB32bpcFloat AlphaPreMulLastRGB32bpcFloat CMYK8bpcInt CMYK16bpcInt CMYK32bpcFloat PlatformDefaultBitmapContext

  • profile (nil, String, Symbol)

    Name of a color profile to use.

  • name (String)

    The name of the object to be created.

Returns:

  • (Command)

    The command to create the bitmap object



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/moving_images/smigcommands.rb', line 374

def self.make_createbitmapcontext(width: 800, height: 600,
                                  size: nil,
                                  preset: :AlphaPreMulFirstRGB8bpcInt,
                                  profile: nil,
                                  name: nil)
  the_command = Command.new(:create)
  the_command.add_option(key: :objecttype, value: :bitmapcontext)
  the_command.add_option(key: :objectname, value: name) unless name.nil?
  if size.nil?
    size = { width: width, height: height }
  end

  the_command.add_option(key: :size, value: size)
  
  unless profile.nil?
    the_command.add_option(key: :colorprofile, value: profile)
  end
  the_command.add_option(key: :preset, value: preset)
  the_command
end

+ (Command) make_createexporter(exportFilePath, export_type: "public.jpeg", name: nil, pathsubstitutionkey: nil)

Make a create image exporter object command

Parameters:

  • exportFilePath (String)

    Path to the file where image exported to

  • export_type (String)

    The uti export file type.

  • name (String)

    The name of the image exporter object to create.

  • pathsubstitutionkey (String, Symbol)

    Get file path from variables dict

Returns:

  • (Command)

    The command to create an image exporter object



428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/moving_images/smigcommands.rb', line 428

def self.make_createexporter(exportFilePath, export_type: "public.jpeg",
                             name: nil, pathsubstitutionkey: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :imageexporter)
  theCommand.add_option(key: :file, value: exportFilePath)
  theCommand.add_option(key: :utifiletype, value: export_type)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  unless pathsubstitutionkey.nil?
    theCommand.add_option(key: :pathsubstitution, value: pathsubstitutionkey)
  end
  theCommand
end

+ (Command) make_createimagefilterchain(filterChain, name: nil)

Make a create image filter chain object command

Parameters:

  • filterChain (Hash, #filterchainhash)

    Filter chain description

  • name (String)

    The name of the image filter chain object to create

Returns:

  • (Command)

    A command to create an image filter chain object



445
446
447
448
449
450
451
452
453
454
# File 'lib/moving_images/smigcommands.rb', line 445

def self.make_createimagefilterchain(filterChain, name: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :imagefilterchain)
  if filterChain.respond_to? "filterchainhash"
    filterChain = filterChain.filterchainhash
  end
  theCommand.add_option(key: :imagefilterchaindict, value: filterChain)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  theCommand
end

+ (Command) make_createimporter(imageFilePath, name: nil, pathsubstitutionkey: nil)

Make a create importer command object.

Parameters:

  • imageFilePath (String)

    A path to an image file

  • name (String)

    The name of the object to be created

  • pathsubstitutionkey (String, Symbol)

    Get file path from variables.

Returns:

  • (Command)

    The command that create the importer



290
291
292
293
294
295
296
297
298
299
300
# File 'lib/moving_images/smigcommands.rb', line 290

def self.make_createimporter(imageFilePath, name: nil,
                             pathsubstitutionkey: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :imageimporter)
  theCommand.add_option(key: :file, value: imageFilePath)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  unless pathsubstitutionkey.nil?
    theCommand.add_option(key: :pathsubstitution, value: pathsubstitutionkey)
  end
  theCommand
end

+ (Command) make_createmovieeditor(name: nil)

Make a create movie editor command object

Parameters:

  • name (String)

    The name of the object to be created.

Returns:

  • (Command)

    The command that will create the movie editor.



349
350
351
352
353
354
# File 'lib/moving_images/smigcommands.rb', line 349

def self.make_createmovieeditor(name: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :movieeditor)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  theCommand
end

+ (Command) make_createmovieimporter(movieFilePath, name: nil, pathsubstitutionkey: nil)

Make a create movie importer command object
The movieFilePath parameter always needs to be assigned even if you just give it an empty string and then have defined pathsubstitutionkey and when the movie importer is created the path is specified in variables dict.

Parameters:

  • movieFilePath (String)

    A path to the movie file

  • name (String)

    The name of the object to be created

  • pathsubstitutionkey (String, Symbol)

    Get file path from variables

Returns:

  • (Command)

    The command that create the importer



310
311
312
313
314
315
316
317
318
319
320
# File 'lib/moving_images/smigcommands.rb', line 310

def self.make_createmovieimporter(movieFilePath, name: nil,
                                  pathsubstitutionkey: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :movieimporter)
  theCommand.add_option(key: :file, value: movieFilePath)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  unless pathsubstitutionkey.nil?
    theCommand.add_option(key: :pathsubstitution, value: pathsubstitutionkey)
  end
  theCommand
end

+ (Command) make_createpdfcontext(size: nil, width: 480, height: 640, filepath: nil, name: nil)

Make a create PDF Context object command. The PDF file will be finalized with everything drawn only when the PDF context object is closed. Initialize the create pdf context command
If filepath is nil when SmigCreatePDFContext is initialized then the file option needs to be set before the command is sent to be performed. The file can be set using:
makePDFContextCommand.add_option(key: :file, value: filePath)

Parameters:

  • width (Fixnum, Float)

    The width of the pdf context to be created.

  • height (Fixnum, Float)

    The height of the pdf context to be created.

  • filepath (String, nil)

    The path to where the file will be created.

  • name (String)

    The name of the pdf context object to create.

Returns:

  • (Command)

    A command to create a pdf context object



468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/moving_images/smigcommands.rb', line 468

def self.make_createpdfcontext(size: nil, width: 480, height: 640,
                               filepath: nil, name: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :pdfcontext)
  if size.nil?
    theCommand.add_option(key: :width, value: width)
    theCommand.add_option(key: :height, value: height)
  else
    theCommand.add_option(key: :size, value: size)
  end
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  theCommand.add_option(key: :file, value: filepath) unless filepath.nil?
  theCommand
end

+ (ObjectComand) make_createtrackcommand(receiver_object, mediatype: :vide, trackid: nil, contexttransformation: nil, affinetransform: nil)

Make a create track command.
Handled by a movie editor object.
This will create a movie track and the track to the movie composition. For version 1.0 the only mediatype allowed is :vide, other mediatypes will be available in future versions. The value returned by the command is the persistent track identifier.

Parameters:

  • receiver_object (Hash)

    Object that will handle the command.

  • mediatype (String, Symbol)

    Media type of track. Currently only vide

  • trackid (Fixnum, nil)

    The persistent track id, which should be unique to the track in the list of tracks in the composition. If nil then a persistent track identifier value will be generated.

  • contexttransformation (Array, nil)

    An array of transformations. Only one of contexttransformation, affinetransform should be specified.

  • affinetransform (Hash, nil)

    A dictionary defining all the elements of an affinetransform. See [MITransformations].

Returns:

  • (ObjectComand)

    The constructed create track command.



861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/moving_images/smigcommands.rb', line 861

def self.make_createtrackcommand(receiver_object,
                                 mediatype: :vide,
                                   trackid: nil,
                     contexttransformation: nil,
                           affinetransform: nil)
  theCommand = ObjectCommand.new(:createtrack, receiver_object)
  theCommand.add_option(key: :trackid, value: trackid) unless trackid.nil?
  theMediaType = mediatype unless mediatype.nil?
  theMediaType = :vide if mediatype.nil?
  theCommand.add_option(key: :mediatype, value: theMediaType)
  unless affinetransform.nil?
    theCommand.add_option(key: :affinetransform, value: affinetransform)
  end
  unless contexttransformation.nil?
    theCommand.add_option(key: :contexttransformation,
                        value: contexttransformation)
  end
  theCommand
end

+ (Command) make_createvideoframeswriter(movieFilePath, utifiletype: com.apple.quicktime-movie, name: nil, pathsubstitutionkey: nil)

Make a create video frames writer command object

Parameters:

  • movieFilePath (String)

    A path to the movie file

  • utifiletype (String, Symbol)

    File type of exported movie file. Possible values are: "com.apple.quicktime-movie", "public.mpeg-4", "com.apple.m4v-video". Respective extensions are mov, mp4, m4v

  • name (String)

    The name of the object to be created

  • pathsubstitutionkey (String, Symbol)

    Get file path from variables with this key.

Returns:

  • (Command)

    The command that will create the importer



331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/moving_images/smigcommands.rb', line 331

def self.make_createvideoframeswriter(movieFilePath,
                         utifiletype: :com.apple.quicktime-movie",
                                name: nil,
                 pathsubstitutionkey: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :videoframeswriter)
  theCommand.add_option(key: :file, value: movieFilePath)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  theCommand.add_option(key: :utifiletype, value: utifiletype)
  unless pathsubstitutionkey.nil?
    theCommand.add_option(key: :pathsubstitution, value: pathsubstitutionkey)
  end
  theCommand
end

+ (Command) make_createwindowcontext(rect: nil, width: 800, height: 600, xloc: 100, yloc: 100, borderlesswindow: false, name: nil)

Make a create window context command.
You can either specify all of width, height, xloc, yloc and not specify rect, or you can specify rect and none of width, height, xloc, yloc.

Parameters:

  • width (Fixnum, Float)

    The content width of the window to be created

  • height (Fixnum, Float)

    Content height of the window to be created.

  • xloc (Fixnum, Float)

    x position of bottom left corner of window

  • yloc (Fixnum, Float)

    y position of bottom left corner of window

  • rect (Hash)

    A representation of a rect MICGDrawing::MIShapes.make_rectangle

  • borderlesswindow (true, false)

    Should the window be borderless?

  • name (String)

    The name of the object to be created.

Returns:

  • (Command)

    The command to create a window context



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/moving_images/smigcommands.rb', line 406

def self.make_createwindowcontext(rect: nil, width: 800, height: 600,
                                  xloc: 100, yloc: 100,
                                  borderlesswindow: false, name: nil)
  theCommand = Command.new(:create)
  theCommand.add_option(key: :objecttype, value: :nsgraphicscontext)
  theCommand.add_option(key: :objectname, value: name) unless name.nil?
  if rect.nil?
    size = { width: width, height: height }
    origin = { x: xloc, y: yloc }
    rect = { size: size, origin: origin }
  end
  theCommand.add_option(key: :rect, value: rect)
  theCommand.add_option(key: :borderlesswindow, value: borderlesswindow)
  theCommand
end

+ (DrawElementCommand) make_drawelement(receiver_object, drawinstructions: nil, createimage: nil)

Make a draw element object command.
If you want to set the draw instructions after making the draw element command then call drawinstructions= on the draw element object. Handled by bitmapcontext, pdf context and windowcontext objects.

Parameters:

  • receiver_object (Hash)

    Object handling the draw element command

  • drawinstructions (Hash, #elementhash)

    The draw instructions.

  • createimage (Bool)

    Create an image of context after render.

Returns:



693
694
695
696
697
698
699
# File 'lib/moving_images/smigcommands.rb', line 693

def self.make_drawelement(receiver_object, drawinstructions: nil,
                          createimage: nil)
  theCommand = DrawElementCommand.new(receiver_object,
                                      drawinstructions: drawinstructions,
                                      createimage: createimage)
  theCommand
end

+ (ObjectCommand) make_export(receiver_object)

Make an Export images to a image file command.

Parameters:

  • receiver_object (Hash)

    Object that receives the export message

Returns:



1172
1173
1174
1175
# File 'lib/moving_images/smigcommands.rb', line 1172

def self.make_export(receiver_object)
  theCommand = ObjectCommand.new(:export, receiver_object)
  theCommand
end

+ (ObjectCommand) make_finalizepdfpage_startnew(receiver_object)

Make a finalize page and start new page command
This command is handled by an object with class type pdfcontext.

Parameters:

  • receiver_object (Hash)

    pdfcontext handles finalize pdf page command

Returns:



1228
1229
1230
1231
# File 'lib/moving_images/smigcommands.rb', line 1228

def self.make_finalizepdfpage_startnew(receiver_object)
  theCommand = ObjectCommand.new(:finalizepage, receiver_object)
  theCommand
end

+ (ObjectCommand) make_finishwritingframescommand(receiver_object)

Make a finish writing frames command
After you have finished adding images to the video writer input you are ready to export the movie. This command will ready the writer for writing the movie file and then write it.

Returns:

  • (ObjectCommand)

    The constructed finish writing frames command.



831
832
833
834
# File 'lib/moving_images/smigcommands.rb', line 831

def self.make_finishwritingframescommand(receiver_object)
  theCommand = ObjectCommand.new(:finishwritingframes, receiver_object)
  theCommand
end

+ (Command) make_get_nonobjectproperty(property: :numberofobjects, type: nil)

Get a property of the moving images framework or a base class type. Some properties require an extra option. For example the filter properties of a filter, requires a filter name option to get the filter properties of a specific filter or if requesting the list of filters that belong to a specific category.
getFilterPropertiesCommand.add_option(key: :filtername, value: "CIBoxBlur")
or
getFiltersInCategory.add_option(key: :filtercategory, value: "CICategoryBlur")
Initialize a get non object property command.

Parameters:

  • property (String, Symbol)

    The property to get.

  • type (String, Symbol, nil)

    Optional class type to get property from

Returns:

  • (Command)

    The get non object property command.



497
498
499
500
501
502
# File 'lib/moving_images/smigcommands.rb', line 497

def self.make_get_nonobjectproperty(property: :numberofobjects, type: nil)
  theCommand = Command.new(:getproperty)
  theCommand.add_option(key: :propertykey, value: property)
  theCommand.add_option(key: :objecttype, value: type) unless type.nil?
  theCommand
end

+ (ObjectCommand) make_get_objectproperties(receiverObject, imageindex: nil, saveresultstype: :jsonstring, saveresultsto: nil)

Make a get object properties command

Parameters:

  • receiverObject (Hash)

    The object to get the properties from

  • imageindex (Fixnum, nil)

    The image index, optional.

  • saveresultstype (String, Symbol)

    :jsonstring, :jsonfile, :propertyfile, :dictionaryobject

  • saveresultsto (String)

    The path to json or property list file.

Returns:



568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/moving_images/smigcommands.rb', line 568

def self.make_get_objectproperties(receiverObject,
                                   imageindex: nil,
                                   saveresultstype: :jsonstring,
                                   saveresultsto: nil)
  theCommand = ObjectCommand.new(:getproperties, receiverObject)
  unless imageindex.nil?
    theCommand.add_option(key: :imageindex, value: imageindex)
  end

  theCommand.add_option(key: :saveresultstype, value: saveresultstype)
  # The saveresultsto option is only relevant if saveresultstype is set
  # to one of :jsonfile or :propertyfile.
  unless saveresultsto.nil?
    theCommand.add_option(key: :saveresultsto, value: saveresultsto)
  end
  theCommand
end

+ (ObjectCommand) make_get_objectproperty(receiverObject, property: :objecttype, imageindex: nil)

Make a get object property command.
A few properties require an extra option to be specified to provide context for the get property option. These can be added using the add_option method. The index of an image within a image importer object is sometimes needed. The image index defaults to 0 if unspecified.

Parameters:

  • receiverObject (Hash)

    The object to get the property from

  • property (String, Symbol)

    The property to get

  • imageindex (Fixnum, nil)

    The image index, optional.

Returns:



551
552
553
554
555
556
557
558
559
# File 'lib/moving_images/smigcommands.rb', line 551

def self.make_get_objectproperty(receiverObject, property: :objecttype,
                                 imageindex: nil)
  theCommand = ObjectCommand.new(:getproperty, receiverObject)
  theCommand.add_option(key: :propertykey, value: property)
  unless imageindex.nil?
    theCommand.add_option(key: :imageindex, value: imageindex)
  end
  theCommand
end

+ (ObjectCommand) make_getpixeldata(receiver_object, rectangle: nil, resultstype: nil, savelocation: nil)

Make a get pixel data command
If the savelocation is not initially specified and resultstype is set to jsonfile or propertyfile then the save location will need to be set using add_option before the get pixel data command is sent.

Parameters:

  • receiver_object (Hash)

    Object that handles the getpixeldata command

  • rectangle (Hash)

    Representing the area to get pixel data from

  • resultstype (:jsonstring, :jsonfile, :propertyfile, :dictionaryobject, nil)
  • savelocation (String, nil)

    path, required if resultstypes is a file

Returns:



1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
# File 'lib/moving_images/smigcommands.rb', line 1206

def self.make_getpixeldata(receiver_object, rectangle: nil,
                           resultstype: nil, savelocation: nil)
  fail "Rectangle not specified" if rectangle.nil?
  theCommand = ObjectCommand.new(:getpixeldata, receiver_object)
  
  unless resultstype.nil?
    theCommand.add_option(key: :saveresultstype, value: resultstype)
  end

  unless savelocation.nil?
    theCommand.add_option(key: :saveresultsto, value: savelocation)
  end

  theCommand.add_option(key: :getdatatype, value: :dictionaryobject)
  theCommand.add_option(key: :propertyvalue, value: rectangle)
  theCommand
end

+ (ObjectCommand) make_insertemptysegment(receiver_object, track: nil, insertiontimerange: nil)

Insert an empty segment into a track.
Handled by a movie editor object. This will add a empty segment to the track

Parameters:

  • receiver_object (Hash)

    Object that will handle the command.

  • track (Hash)

    A track identifier for a track in the receiver object

  • insertiontimerange (Hash)

    The empty time range MIMovie::MovieTime.make_movie_timerange to insert into the track.

Returns:

  • (ObjectCommand)

    The constructed insert track segment command.



928
929
930
931
932
933
934
935
936
937
938
939
# File 'lib/moving_images/smigcommands.rb', line 928

def self.make_insertemptysegment(receiver_object,
                          track: nil,
             insertiontimerange: nil)
  theCommand = ObjectCommand.new(:insertemptytracksegment, receiver_object)
  theCommand.add_option(key: :track, value: track) unless track.nil?
  
  unless insertiontimerange.nil?
    theCommand.add_option(key: :timerange, value: insertiontimerange)
  end
  
  theCommand
end

+ (ObjectCommand) make_inserttracksegment(receiver_object, track: nil, source_object: nil, source_track: nil, insertiontime: nil, source_timerange: nil)

Insert a segment of content into a track.
Handled by a movie editor object. This will add a segment of content to the track taking the content from the source track. The track and source track must both be of the same media type.

Parameters:

  • receiver_object (Hash)

    Object that will handle the command.

  • track (Hash)

    A track identifier for a track in the receiver object

  • source_object (Hash)

    Object containing source track.

  • source_track (Hash)

    The track from which to obtain the content.

  • insertiontime (Hash)

    The time in track where content is inserted MIMovie::MovieTime

  • source_timerange (Hash)

    The time range (start, duration) within the source track time frame from which to get the content to insert.

Returns:

  • (ObjectCommand)

    The constructed insert track segment command.



894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
# File 'lib/moving_images/smigcommands.rb', line 894

def self.make_inserttracksegment(receiver_object,
                          track: nil,
                  source_object: nil,
                   source_track: nil,
                  insertiontime: nil,
               source_timerange: nil)
  theCommand = ObjectCommand.new(:inserttracksegment, receiver_object)
  theCommand.add_option(key: :track, value: track) unless track.nil?
  unless source_object.nil?
    theCommand.add_option(key: :sourceobject, value: source_object)
  end
  
  unless source_track.nil?
    theCommand.add_option(key: :sourcetrack, value: source_track)
  end
  
  unless insertiontime.nil?
    theCommand.add_option(key: :insertiontime, value: insertiontime)
  end
  
  unless source_timerange.nil?
    theCommand.add_option(key: :sourcetimerange, value: source_timerange)
  end
  
  theCommand
end

+ (ObjectCommand) make_movieeditor_export(receiver_object, exportpreset: nil, exportfilepath: nil, exportfiletype: nil, pathsubstitutionkey: nil)

Export the created composition from the movie editor object.
You can get a list of all movie export presets as a get property command directed at the movie editor class. You can obtain a list of export presets compatible with the movie composition using the get property command directed at the movie editor object. Similar applies to the export file type.

Parameters:

  • receiver_object (Hash)

    Object that will handle the command.

  • exportpreset (String)

    The export preset to be used to export the movie

  • exportfilepath (String)

    The path to the where the movie file will be exported. If a file already exists at the export location then it will be deleted before export starts.

  • exportfiletype (String)

    The uti file type to be used for exporting the movie composition.

  • pathsubstitutionkey (String)

    Do path substitution when command processed. This key should be the dictionary key into the variables dict.

Returns:



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
# File 'lib/moving_images/smigcommands.rb', line 1004

def self.make_movieeditor_export(receiver_object,
                            exportpreset: nil,
                          exportfilepath: nil,
                          exportfiletype: nil,
                     pathsubstitutionkey: nil)
  theCommand = ObjectCommand.new(:export, receiver_object)

  unless exportpreset.nil?
   theCommand.add_option(key: :preset, value: exportpreset)
  end

  unless exportfilepath.nil?
   theCommand.add_option(key: :file, value: exportfilepath)
  end

  unless exportfiletype.nil?
   theCommand.add_option(key: :utifiletype, value: exportfiletype)
  end

  unless pathsubstitutionkey.nil?
    theCommand.add_option(key: :pathsubstitution, value: pathsubstitutionkey)
  end
  
  theCommand
end

+ (ProcessFramesCommand) make_processframes(receiver_object)

Make a process frames object command
Handled by a movie importer object. This command allows you to configure the processing of frames of an imported movie. See ProcessFramesCommand for documentation.

Parameters:

  • receiver_object (Hash)

    Movie importer object that handles this command

Returns:



721
722
723
724
# File 'lib/moving_images/smigcommands.rb', line 721

def self.make_processframes(receiver_object)
  theCommand = ProcessFramesCommand.new(receiver_object)
  theCommand
end

+ (Object) make_removeimage_fromcollection(identifier)

Remove an image from the image collection.

Parameters:

  • identifier (String)

    The identifier for the image in the collection.



1163
1164
1165
1166
1167
# File 'lib/moving_images/smigcommands.rb', line 1163

def self.make_removeimage_fromcollection(identifier)
  theCommand = Command.new(:removeimagefromcollection)
  theCommand.add_option(key: :imageidentifier, value: identifier)
  theCommand
end

+ (RenderFilterChainCommand) make_renderfilterchain(receiver_object, renderinstructions: nil, createimage: nil)

Make a render filter chain object command
Handled by a image filter chain object.

Parameters:

  • receiver_object (Hash)

    Filter chain object that handles render

  • renderinstructions (Hash)

    Render instructions and filter properties

  • createimage (Bool)

    Create an image of context after render.

Returns:



707
708
709
710
711
712
713
# File 'lib/moving_images/smigcommands.rb', line 707

def self.make_renderfilterchain(receiver_object, renderinstructions: nil,
                                createimage: nil)
  theCommand = RenderFilterChainCommand.new(receiver_object, 
                                           instructions: renderinstructions,
                                           createimage: createimage)
  theCommand
end

+ (ObjectCommand) make_set_object_exportpathproperty(receiver_object, propertyvalue: nil, pathsubstitutionkey: nil)

Set the export path object property.
Applies only to the exporter object. One of propertyvalue or pathsubsitutionkey needs to be set. If both are set then the substituted path overrides. The substituted path is obtained from the contexts variables dictionary using the pathsubstitutionkey.

Parameters:

  • receiver_object (Hash)

    The object to set the property of

  • propertyvalue (String, Symbol)

    The path to be set.

  • pathsubstitutionkey (String, Symbol)

    The key into the variables dict.

Returns:



624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/moving_images/smigcommands.rb', line 624

def self.make_set_object_exportpathproperty(receiver_object,
                                            propertyvalue: nil,
                                            pathsubstitutionkey: nil)
  theCommand = ObjectCommand.new(:setproperty, receiver_object)
  theCommand.add_option(key: :propertykey, value: :file)

  unless pathsubstitutionkey.nil?
    theCommand.add_option(key: :pathsubstitution, value: pathsubstitutionkey)
  end
  if propertyvalue.nil?
    theCommand.add_option(key: :propertyvalue, value: "")
  else
    theCommand.add_option(key: :propertyvalue, value: propertyvalue)
  end
  theCommand
end

+ (ObjectCommand) make_set_objectproperties(receiver_object, properties, imageindex: nil)

Make a set properties command.
If setting preoperties for images in an image exporter object then it will also be necessary to add a image index option to specify a specific image in the exporter. The image index defaults to 0 if unspecified.

Parameters:

  • receiver_object (Hash)

    The object to set the properties of

  • properties (Hash)

    hash object to be assigned

  • imageindex (nil, Fixnum)

    nil means no index

Returns:



649
650
651
652
653
654
655
656
657
658
659
# File 'lib/moving_images/smigcommands.rb', line 649

def self.make_set_objectproperties(receiver_object, properties,
                                   imageindex: nil)
  fail "properties needs to be a hash" unless properties.is_a?(Hash)
  the_command = ObjectCommand.new(:setproperties, receiver_object)
  the_command.add_option(key: :getdatatype, value: :dictionaryobject)
  the_command.add_option(key: :inputdata, value: properties)
  unless imageindex.nil?
    the_command.add_option(key: :imageindex, value: imageindex)
  end
  the_command
end

+ (ObjectCommand) make_set_objectproperty(receiver_object, propertykey: nil, propertyvalue: nil, imageindex: nil)

Make a set property command.
If setting property values for images in an image exporter object then it will also be necessary to add a image index option to specify a specific image in the exporter. The image index defaults to 0 if unspecified.
set_imagepropertycommand.add_option(key: :imageindex, value: imageindex)

Parameters:

  • receiver_object (Hash)

    The object to set the property of

  • propertykey (String, Symbol)

    The property to be set.

  • propertyvalue (String, Symbol, Fixnum, Float, Hash)

    Value to be set

  • imageindex (nil, Fixnum)

    nil means no index.

Returns:



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/moving_images/smigcommands.rb', line 597

def self.make_set_objectproperty(receiver_object, propertykey: nil,
                                 propertyvalue: nil, imageindex: nil)
  theCommand = ObjectCommand.new(:setproperty, receiver_object)
  unless propertykey.nil?
    theCommand.add_option(key: :propertykey, value: propertykey)
  end
  unless propertyvalue.nil? 
    theCommand.add_option(key: :propertyvalue, value: propertyvalue)
    if propertyvalue.is_a?(Hash)
      theCommand.add_option(key: :getdatatype, value: :dictionaryobject)
    end
  end
  unless imageindex.nil?
    theCommand.add_option(key: :imageindex, value: imageindex)
  end
  theCommand
end

+ (ObjectCommand) make_snapshot(receiver_object, snapshottype: :takesnapshot)

Make a snap shot command

Parameters:

  • receiver_object (Hash)

    Object that will handle snap shot command

  • snapshottype (:takesnapshot, :drawsnapshot, :clearsnapshot)

Returns:



1190
1191
1192
1193
1194
# File 'lib/moving_images/smigcommands.rb', line 1190

def self.make_snapshot(receiver_object, snapshottype: :takesnapshot)
  theCommand = ObjectCommand.new(:snapshot, receiver_object)
  theCommand.add_option(key: :snapshotaction, value: snapshottype)
  theCommand
end