WP Commands


The Ten&Two IMG Processor enables fourteen (14) WP-CLI subcommands. The first three (3) are primarily for debugging and maintenance purposes. Then, there are command equivalents for eleven (11) IMG Processor shortcodes. For in-context details on the available options, use wp img_process --help and wp img_process <subcommand> --help.


version

The version subcommand provides information about the plugin’s PHP environment, specifically, the status of the GD  and ImageMagick  image libraries. The optional --types argument adds a list of supported image formats to the output.

  • wp img_process version [--types]

cache

The cache_clean and cache_delete subcommands facilitate cache management outside of WordPress. The three (3) optional arguments --expire_type, --expire_value, and --cache_path override their respective IMG Processor Settings. If --cache_path is set, the command requires confirmation.

  • wp img_process cache_delete [--cache_path={dirpath}]
  • wp img_process cache_clean [--expire_type={atime|amin|ctime|cmin|mtime|mmin}] [--expire_value={int}] [--cache_path={dirpath}]

transform

Like their shortcode counterparts, most IMG Processor subcommands share several arguments and options. The location of the source image is the only required argument; it is specified by the first positional (unlabeled) argument, <source>. The name and location of the output image can be overridden using the second positional argument, <output_file>. The defaults for --output_type and --output_dpi are configured in the IMG Processor Settings. For the info subcommand, --output=info is the default; for all other subcommands, --output=file is the default result format.

  • <source> : REQUIRED source image file path or URL
  • <output_file> : optional output image path (cache override)
  • --output_type={gif|jpg|png|webp|…} : image format
  • --output_dpi={0|72|…} : max resolution, 0=no change
  • --output={info|json|file|…|img|html|figure} : CLI result format

The remaining arguments for each subcommand match the corresponding shortcode’s attributes.

  • wp img_process info
  • wp img_process fit --width={int} --height={int}
  • wp img_process fill --width={int} --height={int}
  • wp img_process resize --width={int} --height={int}
  • wp img_process crop --top={int} --left={int} --width={int} --height={int}
  • wp img_process trim --top={int} --left={int} --bottom={int} --right={int}
  • wp img_process border --top={int} --left={int} --bottom={int} --right={int} --color_r={0-255} --color_g={0-255} --color_b={0-255} --color_a={0-1.0}
  • wp img_process flip --axis={x|y}
  • wp img_process rotate --degrees={int} --color_r={0-255} --color_g={0-255} --color_b={0-255} --color_a={0-1.0}
  • wp img_process scale --percent={int}
  • wp img_process zoom --percent={int} --focus={X|N|E|S|W|NW|NE|SW|SE} --width={int} --height={int}