-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PNG grayscale support #190
Comments
I need to review the source for the built-in drawing modules. There is common core code used by both the html canvas interface and node that would be impacted by this request. |
I think it best to punt on this issue for right now. Changing the built-in drawing code is problematic as it has no a priori knowledge of color depth. Conversely, it takes very little code to post-process an RGBA PNG to grayscale. For example, using the
Not sure your experience with javascript so if you need more details on this, let me know. |
@metafloor thanks for the pngjs suggestion and sample code! It would be nice to reduce the number of dependencies and have bwip-js generate the desired output, but I'm not constrained on resources for this application, so this is a reasonable approach for now. I'll give this a try and see if InDesign likes it. Looks like pngjs You're welcome to close this issue to reduce the backlog if you prefer that. I don't think this rises to a priority level for me to work on a PR at this time, but if it gets more votes maybe I'll come back to it. I think I understand why this would be a big lift to support. Looks like you're creating the image bitmap in RGBA (either as a canvas buffer or node.js Buffer) Line 36 in d6a5c1e
bwip-js/src/drawing-zlibpng.js Lines 37 to 48 in d6a5c1e
And further manipulation (drawing of foreground shapes, background) is done directly in the RGBA bitmap. bwip-js/src/drawing-builtin.js Lines 301 to 319 in d6a5c1e
So all of that code would have to change to support a grayscale bitmap. |
I think you are misunderstanding the issue. The actual code to produce a gray scale png is not difficult. The issue is knowing when it is safe to do so. For example, |
The feature request
It would be fantastic if bwip-js could export grayscale (monochromatic) PNGs in place of RGB. This would offer more control when printing and when importing into applications that support CMYK. Thanks!
I'm not too familiar with the PNG data structures at the moment, but it seems the place to start adding this functionality would be in
DrawingZlibPng(opts, callback)
bwip-js/src/drawing-zlibpng.js
Line 25 in d6a5c1e
The issue
I'm facing a bit of a challenge when bringing barcode PNGs into Adobe InDesign for CMYK documents. Since bwip-js exports PNGs as RGB, the barcode will print as CMYK(75, 68, 67, 90) which can result in a messy barcode when there's misalignment between the plates. I'm looking for that sweet CMYK(0,0,0,100).
Workaround
Apply a Generic Gray Profile as a post-process step. You can do this pretty quickly in macOS Automator.
Alternative solutions
I'd use CMYK in SVG, but that isn't completely standardized and adopted yet.
If there would be a way to get an EPS out of bwip-js, that could work as well.
The text was updated successfully, but these errors were encountered: