Skip to content
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

Added decoding for base64-encoded images #88

Merged
merged 1 commit into from
Oct 10, 2018
Merged

Added decoding for base64-encoded images #88

merged 1 commit into from
Oct 10, 2018

Conversation

jbednar
Copy link
Member

@jbednar jbednar commented Oct 8, 2018

Right now, Image types accept a binary bytes object and return a base64-encoded HTML representation of the image suitable for embedding in an HTML document. Some packages like Datashader return such a bytes object from their _repr_png_() methods, which works well, but other _repr_png_ methods like the ones in nxpd return a string already base64 encoded. With this PR, if a string is provided as the image data, Panel will base64-decode the string before moving on; it will later be base64 encoded again. This double decoding and subsequent re-encoding isn't optimal, but it's a simple fix for not being able to view such objects.

The code uses isinstance(...,str) to check for the string, which seems safe for py2/py3 because a base64-encoded string should not normally be unicode on either Python version.

@codecov-io
Copy link

Codecov Report

Merging #88 into master will decrease coverage by 0.02%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #88      +/-   ##
==========================================
- Coverage   91.69%   91.67%   -0.03%     
==========================================
  Files          23       23              
  Lines        3674     3676       +2     
==========================================
+ Hits         3369     3370       +1     
- Misses        305      306       +1
Impacted Files Coverage Δ
panel/pane.py 81.36% <50%> (-0.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1547390...44452ba. Read the comment docs.

@philippjfr philippjfr merged commit 49b11d5 into master Oct 10, 2018
@philippjfr philippjfr deleted the base64png branch October 17, 2018 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants