Besides convert, which converts from one file to another, there is mogrify which transforms the file in place. A temporary file is used (if necessary) to ensure that the existing image file is not damaged if something goes wrong (e.g., not enough disk space). Note that unlike some applications supporting DPX/Cineon, when a file is modifed in-place , it is completely re-written. While GraphicsMagick makes every attempt to preserve header information, some previously existing features of the file (such as the offset to the pixel data) may change.
A typical mogrify command is
gm mogrify -resize 1828x1556 -depth 10 file-0001.dpx file-0002.dpx
Multiple files may be specified on the command line so the same command may process hundreds of files in one invocation.
Unix users can use the find and xargs programs to perform operations on any number of files:
find /assets/001 -name '*.dpx' -print | \ xargs gm mogrify -resize 1828x1556 -depth 10
Xargs works by pasting as many file names as possible on the end of the command provided to it.
The GNU version of xargs provides an added benefit. It is able to run several commands in the background. This means that if your system has multiple CPUs, it can take advantage of all the CPUs while still using one command:
find /assets/001 -name '*.dpx' -print | \ xargs --max-procs 3 --max-args 25 gm mogrify -resize 1828x1556 -depth 10
The mogrify command supports the -output-directory option to sent files to a different directory than the input files. This allows processing a large number of files without overwriting the input files:
mkdir dest cd source gm mogrify -output-directory ../dest -resize 1828x1556 -depth 10 '*.dpx'
Note that the entire input file path specification is preserved when composing the output path so that the input file path is simply appended to the output directory path. Also, unless the -create-directories option is added, the user is responsible for creating any necessary destination directories. As an example of the path composition algorithm, if the input file name is specified as source/file.dpx and the output directory is specified as dest, then the output file path will be dest/source/file.dpx.
Here is an incantation which recursively processes all DPX files under source and sends the result to a similar directory tree under dest.
mkdir dest cd source find . name '*.dpx' -print | xargs gm mogrify -output-directory ../dest \ -create-directories -resize 1828x1556 -depth 10
GraphicsMagick may be used to create a contact sheet (grid of thumbnails with name and size) by using the VID pseudoformat which accepts a wildcarded argument of files (protected by quotes!) to read. The output files are buffered while files are being read so there is a practical limit to the number of files which may be processed at once. To output to a Postscript file:
gm convert "vid:*.dpx" "contact-sheet.ps"
or to a PDF file:
gm convert "vid:*.dpx" "contact-sheet.pdf"
or to a sequence of JPEG files ranging from contact-sheet-000.jpg to contact-sheet-999.jpg:
gm convert "vid:*.dpx" "contact-sheet-%03d.jpg"
or to a MIFF file which may be used to interactively browse the original files using 'gm display':
gm convert "vid:*.dpx" "contact-sheet.miff"
GraphicsMagick may be used to animate an image sequence on an X11 display using the animate subcommand. Frames are buffered in memory (pre-loaded into the X11 server) so the number of frames which may be animated at once is limited. GraphicsMagick has been used to animate 1080P (1920x1080) images at 24 frames per second with at least 300 frames in the sequence.More frames may be buffered on 64-bit systems. Many more frames may be animated by preparing a reduced set of frames in advance.
To visualize an animation at 24 frames per second (delay (1/24)*100) use
gm animate -delay 4.17 'Frame_*.dpx'
In order to obtain a preview of a larger sequence, and if the frames are numbered, a broader span of time may be animated by selecting every 10^th frame (terminating with zero) to animate at 2.4 frames per second:
gm animate -delay 41.7 'Frame_*0.dpx'
An image frame may be displayed on an X11 server using the display subcommand. By default the name of the image file is displayed in the title bar. By specifying the format of the title, other useful information such as the time code (see the DPX Attributes section for more details) may be included in the window title:
gm display -title '%f (%[DPX:tv.time.code])' foo.dpx
A sequence of images may be displayed on an X11 server using the display subcommand. Unlike 'gm animate' there are no arbitrary limits when displaying a sequence this way. Unlike 'gm animate' the inter-frame delay can not be set to less than a second (100 ticks is one second).
gm display +progress -delay 100 'Frame_*.dpx'
The following command options are particularly useful when dealing with DPX files:
GraphicsMagick provides almost full access to DPX header attributes. DPX header attributes are shown in the output of 'gm identify -verbose' and may be set using the -define syntax (e.g. '-define dpx:mp.frame.position=2000') on the command line in order to add a value, or override an existing value. The attributes in the list below may be viewed or updated. The names are similar to the attribute descriptions from the DPX standard.
dpx:file.copyright dpx:file.creation.datetime dpx:file.creator dpx:file.encryption.key dpx:file.filename dpx:file.project.name dpx:file.version dpx:image.orientation dpx:mp.count dpx:mp.film.manufacturer.id dpx:mp.film.type dpx:mp.format dpx:mp.frame.id dpx:mp.frame.position dpx:mp.frame.rate dpx:mp.held.count dpx:mp.perfs.offset dpx:mp.prefix dpx:mp.sequence.length dpx:mp.shutter.angle dpx:mp.slate.info dpx:source.aspect.ratio.horizontal dpx:source.aspect.ratio.vertical dpx:source.border.validity.bottom dpx:source.border.validity.left dpx:source.border.validity.right dpx:source.border.validity.top dpx:sou