Skip to content

Instantly share code, notes, and snippets.

@RhetTbull
RhetTbull / adjustments.py
Created February 18, 2021 05:56
Retrieve adjustment/edit data from edited photos in Apple Photos
""" Read adjustments data for photos edited in Apple's Photos.app
In Catalina and Big Sur, the adjustments data (data about edits done to the photo)
is stored in a plist file in
~/Pictures/Photos Library.photoslibrary/resources/renders/X/UUID.plist
where X is first character of the photo's UUID string and UUID is the full UUID,
e.g.: ~/Pictures/Photos Library.photoslibrary/resources/renders/3/30362C1D-192F-4CCD-9A2A-968F436DC0DE.plist
Thanks to @neilpa who figured out how to decode this information:
Reference: https://github.com/neilpa/photohack/issues/4
"""
@RhetTbull
RhetTbull / vision.py
Last active April 3, 2024 17:49
Use Apple's Vision framework from Python to detect text in images
""" Use Apple's Vision Framework via PyObjC to detect text in images
To use:
python3 -m pip install pyobjc-core pyobjc-framework-Quartz pyobjc-framework-Vision wurlitzer
"""
import pathlib
@RhetTbull
RhetTbull / photos_text.py
Last active November 8, 2021 23:29
Extract text from images in MacOS Photos.app using tesseract OCR and update Photo description with extracted text
""" Extract text from images in Photos.app using tesseract and
update Photo description with extracted text """
# NOTE: doesn't currently work well as OCR image needs more pre-processing
# see: https://towardsdatascience.com/optical-character-recognition-ocr-with-less-than-12-lines-of-code-using-python-48404218cccb
import datetime
import pathlib
import osxphotos
@RhetTbull
RhetTbull / photokit.py
Last active February 23, 2024 22:53
Access images from Apple Photos and associated metadata. Uses PyObjC to call native PhotoKit framekwork to access the user's Photos library.
""" Use Apple PhotoKit via PyObjC bridge to download and save a photo
from users's Photos Library
Copyright Rhet Turnbull, 2020. Released under MIT License.
Required pyobjc >= 6.2 see: https://pypi.org/project/pyobjc/ """
import platform
import logging
import sys
import CoreServices
@mrthomaskim
mrthomaskim / install-Python-AmazonLinux-20171023.log
Created June 13, 2018 20:44
Amazon Linux AMI, pyenv, virtualenv, Python, ... Hello, World!
### prerequisites
sudo yum groupinstall "Development Tools"
git --version
gcc --version
bash --version
python --version # (system)
sudo yum install -y openssl-devel readline-devel zlib-devel
sudo yum update
### install `pyenv`
@wpscholar
wpscholar / vagrant-cheat-sheet.md
Last active April 22, 2024 16:02
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@cjoudrey
cjoudrey / twitter.js
Created November 5, 2011 16:37
Lazy-rendering in PhantomJS
// This example shows how to render pages that perform AJAX calls
// upon page load.
//
// Instead of waiting a fixed amount of time before doing the render,
// we are keeping track of every resource that is loaded.
//
// Once all resources are loaded, we wait a small amount of time
// (resourceWait) in case these resources load other resources.
//
// The page is rendered after a maximum amount of time (maxRenderTime)
@eculver
eculver / Simple reversible datetime representation
Created January 5, 2011 01:24
Basic conversion of python datetime to string and back
import datetime
fmt = '%Y%m%d%H%M%S' # ex. 20110104172008 -> Jan. 04, 2011 5:20:08pm
now_str = datetime.datetime.now().strftime(fmt)
now_datetime = datetime.datetime.strptime(now_str, fmt)