-
Notifications
You must be signed in to change notification settings - Fork 622
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
feat: Add XBM encoder #2341
feat: Add XBM encoder #2341
Conversation
cd4dc2a
to
2bfdc76
Compare
2bfdc76
to
ad5c3d5
Compare
Are you using XBM for anything in particular? I'm not sure whether we support writing Also we should probably document this more clearly, but the |
@fintelia This format is useful for generating a QR code. QR code can be converted from PNG or PBM images using ImageMagick, but it is more useful to be able to generate a XBM image directly. I'm developing a command to generate QR code (https://crates.io/crates/qrtool), and this change will allow me to add XBM as an output format. If |
|
I'm not sure I follow. QR codes are 2D barcodes, they aren't tied to any specific image format. Are you using some specific software that understands XBM files but not PNG? |
|
No, I don't use such software. XBM is old, so I think the demand for this format is low. In most cases, I think using ImageMagick to convert a PNG image to a XBM image will be enough. However, if you can generate XBM images directly, you can get XBM images even if you don't have ImageMagick (or commands which can convert any other image format to XBM) installed, so I think it would be somewhat convenient.
How can I fix the code? |
I suspect demand for this format is low, so rather than adding an encoder to this crate it might be better to create a separate crate for the format. |
I changed the methods to take a 8-bit grayscale image ( |
I still don't understand relationship to qr codes. Does the QR spec use XBM somehow? Can you embed an image inside a QR code? |
@kornelski QR code and XBM are unrelated. First of all, QR code is a type of barcode and not an image. I mentioned QR code as an example of a binary image. Photos can also be represented as binary images, but I think they are usually represented as RGB images. |
I intend to develop a separate crate for encoding (and hopefully decoding) XBM. If possible, I would like to support XBM in this crate in a similar way to QOI. |
I'll open another PR once I create a crate for XBM. |
You should totally publish your own crate for XBM encoding. As far as adding support to |
@fintelia I agree that XBM is lesser-known. Based on this discussion, even after an XBM implementation is developed, I don't intend to add support for XBM to this crate. |
I license past and future contributions under the dual MIT/Apache-2.0 license,
allowing licensees to choose either at their option.
This is an initial encoder for XBM image file format (not XPM).
The following image (◻️ = 0, ◼️ = 1):
Represent this as a Rust array like the following (represents a 8-bit grayscale image):
Encode this array as follows:
Result:
I checked the encoded XBM images using an image viewer and it seems to be generated as expected.