Ejemplo n.º 1
0
func setKeywords(img *model.Image, path string, kwds []string) error {
	// charset issues?
	// log.Printf("%s: kwds: %d\n", path, len(kwds))
	tmp := "/tmp/k.txt"
	text := "2#25#Keyword=" + strings.Join(kwds, ";")
	err := ioutil.WriteFile(tmp, []byte(text), 0777)
	if err != nil {
		return err
	}
	cmd := exec.Command(
		*model.BinRoot+"mogrify", "-comment", "JFIFComment", "-profile",
		"8BIMTEXT:"+tmp, path)
	out, err := cmd.Output()
	if err != nil {
		log.Printf("%v: %s\n", cmd.Args, out)
		return err
	}
	os.Chtimes(path, img.FileTime(), img.FileTime())
	return nil
}