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

Feature request: render-images in pins #31

Open
robmarkcole opened this issue Feb 18, 2021 · 3 comments
Open

Feature request: render-images in pins #31

robmarkcole opened this issue Feb 18, 2021 · 3 comments

Comments

@robmarkcole
Copy link

Hi Simon
I have installed both this and datasette-render-images plugins and have a table with lat/lon and also a blob image I wish to display. However with both plugins installed the images are no longer rendered (they are if only render-images is installed). I assume there is some compatibility issue?
Cheers

image

@robmarkcole
Copy link
Author

Alright it seems I had not actually had the datasette-render-images installed at the time above. When installing with docker it seems only the last package installed was actually being commited. To get both installed I had to pip install them at the same time: docker run datasetteproject/datasette pip install datasette-render-images datasette-cluster-map

Doing this the images are rendered in the table, but it would be nice to see them in the pin also:

image

@robmarkcole robmarkcole changed the title Feature request: compatibility with datasette-render-images Feature request: render-images in pins Feb 18, 2021
@simonw
Copy link
Owner

simonw commented Feb 18, 2021

datasette-cluster-map has a mechanism for displaying images in the marker, but it works for images that have a URL - not for images that are stored directly in BLOB columns. https://datasette.io/plugins/datasette-cluster-map#user-content-custom-marker-popups

You can use https://datasette.io/plugins/datasette-media to set up URLs that can serve images directly from BLOB columns, so you could use the combination of datasette-cluster-map and datasette-media to solve this, but there would be quite a bit of configuration involved.

I wonder if this could be made simpler?

@robmarkcole
Copy link
Author

robmarkcole commented Feb 18, 2021

The full sized images are actually stored on S3 in a private bucket, and these blobs are thumbnails for quick viewing. So it would be nice not to have the dependency on local files or public URL. Your suggestion of using datasette-media sounds fine, perhaps an example in the docs for config would suffice?

Alternatively here is what I am doing in folium, which might be helpful?

import folium
from folium import IFrame

# save thumbnail as 'tmp.jpg'
encoded = base64.b64encode(open('tmp.jpg', 'rb').read()).decode('UTF-8')
svg = f"""<object data="data:image/jpg;base64,{encoded}" width="1000" height="800 type="image/svg+xml"></object>"""

iframe = IFrame(svg, width=width*fat_wh, height=height*fat_wh)
popup  = folium.Popup(iframe, parse_html = True, max_width=2000)

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

No branches or pull requests

2 participants