cmd

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Copyright © 2024 Achno <EMAIL ADDRESS>

Copyright © 2024 Achnologia <EMAIL ADDRESS>

Copyright © 2024 Achno <EMAIL ADDRESS>

Copyright © 2025 Achno <EMAIL ADDRESS>

Copyright © 2024 Achnologia <EMAIL ADDRESS>

Copyright © 2024 Achnologia <EMAIL ADDRESS>

Copyright © 2024 Achnologia <EMAIL ADDRESS>

Copyright © 2024 Achno <EMAIL ADDRESS>

Copyright © 2024 Achnologia <EMAIL ADDRESS>

Copyright © 2024 Achno <EMAIL ADDRESS>

Index

Constants

This section is empty.

Variables

View Source
var BorderCmd = &cobra.Command{
	Use:   "border [PATH] [OPTIONAL OUTPUT]",
	Short: "draw a border with a specified  color and thickness on the image",
	PreRunE: func(cmd *cobra.Command, args []string) error {
		err := validateInput(shared, args)
		if err != nil {
			return err
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		hex, err := cmd.Flags().GetString("color")
		utils.HandleError(err, "Error")

		clr, err := image.HexToRGBA(hex)
		utils.HandleError(err, "Error")

		processor := &image.BorderProcessor{
			Color:           clr,
			BorderThickness: BorderThickness,
		}

		imageOps, err := imageio.DetermineImageOperations(shared, args)
		utils.HandleError(err)

		logger.Print("Processing images...")

		processedImages, err := image.ProcessImgs(processor, imageOps, theme)
		utils.HandleError(err, "Error")

		if err != nil {
			logger.Error(err, "The following images had errors while processing")
		}

		openImageInViewer(shared, args, processedImages[0])
	},
}
View Source
var (
	BorderThickness int
)
View Source
var GridCmd = &cobra.Command{
	Use:   "grid [PATH] [OPTIONAL OUTPUT]",
	Short: "draw a grid with a specific size,color and thickness on the image",
	PreRunE: func(cmd *cobra.Command, args []string) error {
		err := validateInput(shared, args)
		if err != nil {
			return err
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		imageOps, err := imageio.DetermineImageOperations(shared, args)
		utils.HandleError(err)
		logger.Print("Processing images...")

		processor := &image.GridProcessor{}
		processor.SetGridOptions(
			image.WithGridSize(gridSize),
			image.WithGridColor(gridColor),
			image.WithGridThickness(gridThickness),
			image.WithMaskonly(gridMask),
		)
		processedImages, err := image.ProcessImgs(processor, imageOps, theme)
		utils.HandleError(err, "Error")

		if err != nil {
			logger.Error(err, "The following images had errors while processing")
		}
		openImageInViewer(shared, args, processedImages[0])
	},
}
View Source
var ScaleFactor float64

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

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