-
-
Notifications
You must be signed in to change notification settings - Fork 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
Switch photo gallery to photoswipe #37
Comments
One catch: photoswipe needs the image height and width, which I don't currently store anywhere. I can get that from the JSON API for imgix using https://niche-museums.imgix.net/misalignment-museum-3.jpeg?fm=json |
I'm going to cache that JSON in full in |
Next step: load the for json_file in *.json; do
echo $json_file
sqlite-utils insert ../browse.db photos "$json_file" --flatten --convert "def convert(row):
row['filename'] = '$json_file'
return row
" --pk filename --alter --replace
done |
The neatest way to do this would be to load that detailed metadata into a But I don't want to rewrite my SQL queries that generate the RSS feed just yet, so I'm going to do a cheaper version that just creates a |
This worked, but is really slow: for json_file in photos-metadata/*.json; do
sqlite-utils insert browse.db raw_photos \
--pk=filename \
--replace \
--alter \
--silent \
--convert "def convert(row):
row['filename'] = '$(basename $json_file .json)'
return row
" \
$json_file
done I'll write it as a Python script instead. |
SQL to get photos for a museum: select
json_extract(j.value, '$.url')
from
museums,
json_each(photos) j
where
museums.id = 111 Demo. |
And to get the width/height from that new with urls as (select
json_extract(j.value, '$.url') as url
from
museums,
json_each(photos) j
where
museums.id = 111)
select url, width, height from photos where url in (select url from urls)
`` |
GPT-4 says:
|
So if it's 6 or 8 I should swap width and height. |
Here's a fun query against select
json_object(
'image', 'https://niche-museums.imgix.net/' || filename || '?w=600',
'title', filename
) as popup,
case
when json_extract(GPS, '$.LatitudeRef') = 'S'
then -1 * json_extract(GPS, '$.Latitude')
else json_extract(GPS, '$.Latitude')
end as latitude,
case
when json_extract(GPS, '$.LongitudeRef') = 'W'
then -1 * json_extract(GPS, '$.Longitude')
else json_extract(GPS, '$.Longitude')
end as longitude
from
raw_photos
where json_extract(GPS, '$.Latitude') is not null Had to take the |
Deployed to https://www.niche-museums.com/ |
Bonus query - this one shows my Niche Museums photographic history in terms of the different lenses I used to take the photos: |
Mentioned in my weeknotes: https://simonwillison.net/2023/Apr/23/weeknotes/ |
I used it for this and really liked it: https://simonwillison.net/2022/May/16/weeknotes/
The text was updated successfully, but these errors were encountered: