Does anyone have a CLI image converter script?

Posted on
  • Hi! I need to convert multiple PNG files to compressed image strings and doing so via online image converter (which is awesome for small tasks by the way!) can get a bit tedious. Does anyone have a command line tool for that?

    Thank you!

  • There isn't anything, but you could add one. The tools are at https://github.com/espruino/EspruinoWebT­ools

    So all you have to do is copy imageconverter.js and use require("imageconverter.js") to use the tools in Node.js.

    Since Canvas/etc isn't really provided in Node.js you'd have to use some other image loader and then just pass the RGBA data into imageconverter's RGBAtoString function though.

  • ... also down the bottom of http://www.espruino.com/Graphics#renderi­ng there are instructions on using ImageMagick to create an image on the command-line, but they are quite basic and deal only with creating the buffer part of the image - not width/height/etc

  • Thanks Gordon! I found an alternative approach: hacking around the Webtool's

      function handleFileSelect(event) {
          if (event.target.files.length != 1) return;
    

    :)

  • That's a neat idea! If you've got something that works nicely it'd be great if you could contribute that back - it could be really handy if https://www.espruino.com/Image+Converter­ accepted multiple files

  • Of course! If I have success in that direction I will send a PR.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Does anyone have a CLI image converter script?

Posted by Avatar for tipishev @tipishev

Actions