html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,issue,performed_via_github_app
https://github.com/dogsheep/dogsheep-photos/issues/20#issuecomment-624408738,https://api.github.com/repos/dogsheep/dogsheep-photos/issues/20,624408738,MDEyOklzc3VlQ29tbWVudDYyNDQwODczOA==,9599,2020-05-06T02:21:05Z,2020-05-06T02:21:32Z,MEMBER,"Here's rendering code from my hacked-together not-yet-released S3 image proxy:
```python
from starlette.responses import Response
from PIL import Image, ExifTags
import pyheif
for ORIENTATION_TAG in ExifTags.TAGS.keys():
if ExifTags.TAGS[ORIENTATION_TAG] == ""Orientation"":
break
...
# Load it into Pillow
if ext == ""heic"":
heic = pyheif.read_heif(image_response.content)
image = Image.frombytes(mode=heic.mode, size=heic.size, data=heic.data)
else:
image = Image.open(io.BytesIO(image_response.content))
# Does EXIF tell us to rotate it?
try:
exif = dict(image._getexif().items())
if exif[ORIENTATION_TAG] == 3:
image = image.rotate(180, expand=True)
elif exif[ORIENTATION_TAG] == 6:
image = image.rotate(270, expand=True)
elif exif[ORIENTATION_TAG] == 8:
image = image.rotate(90, expand=True)
except (AttributeError, KeyError, IndexError):
pass
# Resize based on ?w= and ?h=, if set
width, height = image.size
w = request.query_params.get(""w"")
h = request.query_params.get(""h"")
if w is not None or h is not None:
if h is None:
# Set h based on w
w = int(w)
h = int((float(height) / width) * w)
elif w is None:
h = int(h)
# Set w based on h
w = int((float(width) / height) * h)
w = int(w)
h = int(h)
image.thumbnail((w, h))
# ?bw= converts to black and white
if request.query_params.get(""bw""):
image = image.convert(""L"")
# ?q= sets the quality - defaults to 75
quality = 75
q = request.query_params.get(""q"")
if q and q.isdigit() and 1 <= int(q) <= 100:
quality = int(q)
# Output as JPEG or PNG
output_image = io.BytesIO()
image_type = ""JPEG""
kwargs = {""quality"": quality}
if image.format == ""PNG"":
image_type = ""PNG""
kwargs = {}
image.save(output_image, image_type, **kwargs)
return Response(
output_image.getvalue(),
media_type=""image/jpeg"",
headers={""cache-control"": ""s-maxage={}, public"".format(365 * 24 * 60 * 60)},
)
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",613006393,
https://github.com/dogsheep/dogsheep-photos/issues/20#issuecomment-624408370,https://api.github.com/repos/dogsheep/dogsheep-photos/issues/20,624408370,MDEyOklzc3VlQ29tbWVudDYyNDQwODM3MA==,9599,2020-05-06T02:19:27Z,2020-05-06T02:19:27Z,MEMBER,"The plugin can be generalized: it can be configured to know how to take the URL path, look it up in ANY table (via a custom SQL query) to get a path on disk and then serve that.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",613006393,
https://github.com/dogsheep/dogsheep-photos/issues/20#issuecomment-624408220,https://api.github.com/repos/dogsheep/dogsheep-photos/issues/20,624408220,MDEyOklzc3VlQ29tbWVudDYyNDQwODIyMA==,9599,2020-05-06T02:18:47Z,2020-05-06T02:18:47Z,MEMBER,"The `apple_photos` table has an indexed `uuid` column and a `path` column which stores the full path to that photo file on disk.
I can write a custom Datasette plugin which takes the `uuid` from the URL, looks up the path, then serves up a thumbnail of the jpeg or heic image file.
I'll prototype this is a one-off plugin first, then package it on PyPI for other people to install.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",613006393,