dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
965 stars 33 forks source link

imagemagick hangs 😞 #271

Open reggi opened 1 month ago

reggi commented 1 month ago

I have a command here:

convert -background white -font "/System/Library/Fonts/Supplemental/Comic Sans MS.ttf" -pointsize 30 label:meow  png:- | identify -format "%w" -
77

For some reason this just hangs:

#!/usr/bin/env -S deno run --allow-all
import $ from "@david/dax"; // "dax-sh" in Node

async function getImageWidth(opts: {
  font: string;
  fontSize: number;
  text: string;
  trim?: boolean;
}) {
  const { font, fontSize, text, trim } = opts;
  const shouldTrim = trim ? "-trim" : "";
  return await $`convert -background white -font ${font} -pointsize ${fontSize} label:${text} ${shouldTrim} png:- | identify -format "%w" -`.text();
}

console.log(
  await getImageWidth({
    font: "/System/Library/Fonts/Supplemental/Comic Sans MS.ttf",
    fontSize: 30,
    text: "meow",
  })
);