Skip to content

unable to use with binary stdout #86

Description

@majelbstoat

I'm using exec.Cmd() to run graphics magick to convert an image, reading from stdin and writing to stdout.

	stdout := bytes.Buffer{}
	stderr := bytes.Buffer{}
	gm := exec.Command("gm", "convert", args...)
	gm.Stdin = bytes.NewReader(img.Data)
	gm.Stdout = &stdout
	gm.Stderr = &stderr

	err = gm.Run()
	if err != nil {
		return nil, fmt.Errorf("gm: %s", stderr.String())
	}
	new := stdout.Bytes()

I've been using go-cmd for all my other commands, but for this use case, it doesn't seem possible, because go-cmd treats all its outputs as strings. Is that correct? I'd love to be doing other work while I wait for the conversion to finish.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions