cmd

package
v0.0.0-...-95ecd7c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "rgba-channel-merge <image-filepath> <image-channel-mask> [(<image-filepath> <image-channel-mask>)...] <output-png-file-path>",
	Short: "image channel merge tool",
	Long: `A tool to merge specific color channels of multiple images into one rgba image.

The channel masks for each image should match the regex [rgbax]{4}, with r, g, b, and a representing the red, green, blue and alpha channel, and x meaning that this channel should be ignored. E.g., the channel mask "rbax" would mean that the first (red) channel of the input image will be used as the red channel for the output image, the second (green) will be used as the blue channel, the third (blue) will be used as alpha channel, and the fourth (alpha) will be ignored.`,
	Run: func(cmd *cobra.Command, args []string) {
		imgs, outputPath, err := parseArgs(args)
		if err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(1)
		}

		maxSize, err := imgs.openImages()
		if err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(2)
		}

		outImg := image.NewNRGBA(image.Rectangle{Min: image.Point{0, 0}, Max: maxSize})
		draw.Draw(outImg, outImg.Bounds(), &image.Uniform{color.RGBA{0, 0, 0, 255}}, image.ZP, draw.Src)

		imgs.mergeChannels(outImg)

		outFile, err := os.Create(outputPath)
		if err != nil {
			fmt.Fprintf(os.Stderr, "%s\n", err)
			os.Exit(3)
		}
		defer outFile.Close()

		png.Encode(outFile, outImg)
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL