favicon

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:  "favicon",
	Args: cobra.NoArgs,

	RunE: func(cmd *cobra.Command, args []string) (err error) {
		defer try.Handle(&err)
		color := try.E1(cmd.Flags().GetString("color"))
		prefix := try.E1(cmd.Flags().GetString("prefix"))
		try.E(os.MkdirAll(filepath.Join(prefix, "ico"), o.DirPerm()))
		try.E(os.MkdirAll(filepath.Join(prefix, "png"), o.DirPerm()))
		try.E(os.MkdirAll(filepath.Join(prefix, "svg"), o.DirPerm()))
		for letter := 'a'; letter <= 'z'; letter++ {
			ico := filepath.Join(prefix, "ico", fmt.Sprintf("%c.ico", letter))
			png := filepath.Join(prefix, "png", fmt.Sprintf("%c.png", letter))
			svg := filepath.Join(prefix, "svg", fmt.Sprintf("%c.svg", letter))
			try.E(download.Download(svgURL(letter), svg))
			args := []string{"magick",
				"convert",
				"-background",
				"none",
				svg,
				"-fill",
				color,
				"-colorize",
				"100",
				"-resize",
				"512x512",
				"-gravity",
				"center",
				"-extent",
				"512x512",
			}
			try.E(ex.Command(args[0], append(args[1:], png)...).Bind().Run())
			try.E(ex.Command(args[0], append(args[1:], "-resize", "128x128", ico)...).Bind().Run())
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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