-
Notifications
You must be signed in to change notification settings - Fork 13
Initial attempt to add palette support #11
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
Conversation
|
Thanks for looking into this! I was just working on supporting 1, 2 and 4 |
|
This was added in response to this question: |
|
But probably needs more work to make sure it doesn't break something, like selecting an invalid bit_depth |
Codecov Report
@@ Coverage Diff @@
## master #11 +/- ##
==========================================
+ Coverage 66.40% 70.66% +4.26%
==========================================
Files 4 4
Lines 256 300 +44
==========================================
+ Hits 170 212 +42
- Misses 86 88 +2
Continue to review full report at Codecov.
|
|
@lwabeke, since this feature is really useful and you laid down the groundwork, I took the liberty and finished it. Currently, we could only support 8-bit palettes; 1, 2 and 4-bit depths need a little bit more packing work to happen. One thing I'm not happy about: Currently, when you could provide a vector of cc: @ianshmean |
|
Thanks, I took a few stabs in the dark and it seemed very promising, but you took it a lot further. Yes, the zero-based indexing could be confusing since Julia is mostly 1 based. I guess you could try to autodetect it, if min(image) == 0, assume zero-based, if max(image) == length(palette), assume 1-based, then correct offset. But you are left with the potential inconsistent/weird behaviour if extrema of image doesn't go to the palette edges. with the convert function of OneBasedIndexing applying the -1 offset correction, something like I'm not sure if you need the Base.convert or if there is a way to get Julia to automatically call the convert, without having to provide the extra specialisation to save |
|
I haven't reviewed this, but just a brief comment to consider leveraging IndirectArrays (which is a tiny package) and OffsetArrays for the zero-based indexing. |
|
Sounds like a good strategy. @Drvi I think you have a much better handle on this than me. Feel free to merge when you think it's ready. I'd just suggest that we also check impact on package load time, but I can't imagine that would change much |
|
Seems like travis's windows isn't letting go of the test files before the cleanup happens. Given clean-up isn't critical on CI, perhaps just disable the cleanup on CI function is_ci()
get(ENV, "TRAVIS", "") == "true" ||
get(ENV, "APPVEYOR", "") in ("true", "True") ||
get(ENV, "CI", "") in ("true", "True")
end
if !is_ci()
# Cleanup
isdir(PNG_TEST_PATH) && rm(PNG_TEST_PATH, recursive = true)
end |
|
Just fyi, I'm working on this. For symmetry, I'd like to allow reading paletted PNGs as IndirectArrays with OffsetArray palette, but there are some cases in PNGSuite images that give me a hard time. |
|
Not sure what is going on with the FreeBSD, but I'm gonna merge this so we can move forward. Thanks everybody! |
|
Awesome. Just an afterthought, but is this worth a read/write example in the readme? |
Allows saving of files using palette table
Example usage below: