metafloor / zpl-image Goto Github PK
View Code? Open in Web Editor NEWPure javascript conversion of PNG, JPEG, GIF files to ZPL GRF bitmaps encoded with Z64.
License: Other
Pure javascript conversion of PNG, JPEG, GIF files to ZPL GRF bitmaps encoded with Z64.
License: Other
I'm rendering my label in a canvas element. I'm drawing black on white for the label contents.
I'm calling imageToZ64(canvas);
to generate the ZPL from my canvas.
What's weird is the ZPL appears to drop all white pixels on the top and left of my canvas, so to get my label to print properly in the center I have to put a black border around the perimeter of the canvas.
Is this expected behavior, or am I doing something wrong?
Some low-end printer does NOT support Z64 format, however ASCII is workable.
Hello, can you add typescript support for this lib?
I'm using zpl-image in a react app, within the browser. I had to add node polyfills to make it even partially happy (zlib, stream, assert), which is a pain because CRA doesn't make it easy to configure webpack. I had to add a library called craco
to enable the polyfills.
zlib isn't even used, but the way the module is structured I had to set up a polyfill for it.
Also, pako seems to be expected to be at window.pako. To make sure it was in scope, I had to add this to my code:
import pako from 'pako';
window.pako = pako;
It'd be nice to not have to dance around this to get it to work, like just import { imageToZ64 } from 'zpl-image';
Why is pako included in the repo when there is an npm package? Also the included pako.js seems to have some minified code at the top.
Great library otherwise! Thanks a lot for writing it!
The image I am inputting is already in greyscale (black & white). After conversion the resulting image in ZPL is quite pixelated and missing a lot of detail, and kind of hard to read.
Is there any way to retain the original image and just convert to ZPL only? No need for monochrome rotation etc.
Hey,
I'm sorry if I'm missing something obvious, but is it possible to convert ZPL to an image or a PDF using this library? Basically into anything that can be embedded into a browser page.
Thank you!
Been trying to use this in Angular but having trouble getting it identified as a library. Not sure you have any experience with this platform but any idea how to import the library?
let id= document.getElementById("image");
let res = imageToZ64(id,{notrim:true,black:56, rotate:'I',height:id['height']});
let zpl = "^XA^LH0,0^FWN^PON^PMN^LRN^FO10,10^GFA,"+ res['length'] +","+ res['length'] +","+ res['rowlen'] +","+ res['z64'] +" ^XZ".
Hello, I have a problem here. Can anyone tell why only the half of the image is converting. That it is only converting width upto 192 px.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.