Support reading from stdin, writing to stdout in HEIC2PNG
Here's a first cut at my proposed changes. I don't do Windows (Mac & Linux–so far only tested on Mac), so you'll have to take care of seeing if things still work there. I will check to make sure it works on Linux.
I wouldn't assume I have this all correct. We should have a bit of back-and-forth in the review/comment section of the PR to make sure I haven't unwittingly broken something. At any rate, the current tests do pass.
Not directly related to this PR, I put together a simple HEIC-to-PPM script which treats command-line files the way I typically expect things to work in a Unix pipeline filter application. (You'll have to rename it to switch "txt" to "py".) It uses the openio() function I mentioned from my csvprogs repo. It also uses libmagic through the python-magic front-end. I have no idea if libmagic is available on Windows. That should be a more robust way to determine the underlying input file type than just the file extensions.
heictopnm.txt
... I have no idea if
libmagicis available on Windows. That should be a more robust way to determine the underlying input file type than just the file extensions. heictopnm.txt
I tried installing python-magic on Windows but failed. According to the official instructions, use pip install python-magic-bin for installation on Windows.
Collecting python-magic-bin
Downloading python_magic_bin-0.4.14-py2.py3-none-win_amd64.whl.metadata (710 bytes)
Downloading python_magic_bin-0.4.14-py2.py3-none-win_amd64.whl (409 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 409.3/409.3 kB 1.4 MB/s eta 0:00:00
Installing collected packages: python-magic-bin
Successfully installed python-magic-bin-0.4.14
The issue is that macOS and Ubuntu require additional installations (via apt or brew), which might cause inconvenience for users.
I wonder if there's a way to strike a balance.
Your question just reminded me—I'm exploring alternative ways to further reduce the size of converted PNG files. While using pngquant, I encountered an issue: a UnicodeDecodeError indicating an invalid continuation byte in the scripts/pngquant file.
This might need to be addressed as a separate issue.
Your question just reminded me—I'm exploring alternative ways to further reduce the size of converted PNG files. While using pngquant, I encountered an issue: a
UnicodeDecodeErrorindicating an invalid continuation byte in thescripts/pngquantfile. This might need to be addressed as a separate issue.
Sounds like at least a test case to capture this problem would be a good first step.
The issue is that macOS and Ubuntu require additional installations (via apt or brew), which might cause inconvenience for users.
I wonder if there's a way to strike a balance.
I suspect that's a known issue for people who care about python-magic. I realized pretty quickly that it wasn't on my Mac, so brew install libmagic fixed it. I was mildly surprised the python-magic installation didn't sniff around and warn me the underlying library was missing. It's already installed on my very old Ubuntu laptop, perhaps as a side-effect of installing some other package. (I don't recall explicitly installing it, but my brain ain't what it used to be, so perhaps I did.)
I'd submit a bug report/feature request to the python-magic folks asking for a post-install check for libmagic.
I apologize for the delayed response as work has been quite busy recently. I suggest letting this PR go through the CI/CD process first, and if everything looks good, we can proceed with this version. I’ll make adjustments to any additional engineering aspects as needed.
Oh no, I think we should remove Python 3.7 from the action.
I will first merge it into another branch and organize it shortly.