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

EXIF support #499

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

EXIF support #499

wants to merge 18 commits into from

Conversation

skybldev
Copy link
Contributor

@skybldev skybldev commented Aug 6, 2022

This PR aims to cherry-pick and merge EXIF-related features into the project. Addresses #470 and #311.

Proposed Features

(mostly copypasted from my fork's README)

  • EXIF orientation support
    • Acknowledges EXIF orientation and generates thumbnails and post dimensions correctly
    • Images with orientations other than 1 now render properly

Notices

  • Date taken does not work with image formats that lack EXIF support (such as PNG) or have been stripped of EXIF metadata.
  • The current migration does not regenerate post thumbnails or fix post dimensions. This will be fixed soon.
  • This fork might be less stable than upstream, since the changes I've made have not been tested on as large of a scale, and I haven't written unit tests for it yet.

- [server] created basic utility for resolving date taken @ `func/metadata.py`
- [server] utilize `func/metadata.py` in `func/posts.py`
- [server] created Alembic migration that adds `date_taken` column to `post`
- [server] updated `model/post.py:Post` to have new column
- [client] added `date-fns` as dependency (it's much cleaner to format
  dates this way)
- [client] added basic sidebar stuff in `html/post_readonly_sidebar.tpl`
- [client] updated `js/models/post.js` to reflect changes
- [client] added `formatUserFriendlyTime()` in `js/util/misc.js`
- [client] added `makeUserFriendlyTime()` in `js/util/views.js` in
  conjunction with it
- [misc] ran post-commit; previous commits did not
- [server] added date taken detection for videos in `func/metadata.py`
  using subprocess and ffmpeg
- [client] only show date taken section on "image" or "video" post type,
  since only they can possess date taken metadata
  (`client/html/post_readonly_sidebar.tpl`)
- [server] attempt to use DateTimeOriginal in `func/metadata.py` to
  resolve date taken (compatibility issue originally found in photo
  taken on LG Optimus L90)
- [overview] implemented filtering and sorting by date taken, optionally
  with null.
- [server] added `SORT_DESC_NULL_LAST` search token in `search/tokens.py`,
  `search/base_search_config.py`
- [server] implemented `SORT_DESC_NULL_LAST` functionality in
  `search/executor.py`
- [server] added date taken search aliases in
  `search/configs/post_search_config.py`
- [server] added `NullCriterion` in `search/criteria.py`; it's literally
  null
- [server] implemented filtering by null for date criterion in
  `search/configs/util.py`
- [server] aliased `NullCriterion` to "null", "none", "unknown", or "?" in
  `search/parser.py`
- [server][minor] added "posted" and "edited" aliases to creation_date
  and last_edit_date
- [server] wrapped exif image reading in a try..except, since it can
  fail for some images. Also added a logger message to make it easier to
  debug in the future, to fix compatibility issues and make debugging
  easier
- [overview] add camera attribute to posts. parsing is done in
  `func/metadata.py` and takes any of the available tags corresponding
  to "make" and "model" properties and concatenates them into a string
- [server] improved `func/metadata.py`:
  - added camera resolve functions for photos and videos
  - moved ffmpeg subprocess and exif image opening to separate function
  - optionally reuse existing collection of extracted tags in any of the
    functions
  - iterative approach to checking for tags' existence as opposed to
    imperative
  - (somewhat) better error handling
- [server] created alembic migration in `adb2acef2492_add_camera.py`
  - not only adds columns, but also scans files and updates their camera
    string
- [server] added camera attribute functionality and improved error
  handling in `func/posts.py`
- [server] add camera attribute to `model/post.py`
- [client] also revised date-taken section
- [overview] this commit fixes an issue where some images would be rendered
  stretched in a browser due to a swapped width and height because of
  intentional EXIF orientation mechanics.
- [server] `func/metadata.py`: added function to resolve the image's
  dimensions after taking the EXIF orientation into consideration. normally,
  this would only be done on the client side; however, since the server takes
  those values into consideration for its own operations, it could also be
  considered a "client". for example, thumbnail generation also depends on the
  post's dimensions.
- [server] `func/posts.py`: refactored `update_post_content`. `func/images.py`
  will no longer be used to determine the dimensions of a file since
  `func/metadata.py` is now responsible for that.
- [server] refactored `func/metadata.py`
- [TODO] create migration to correct post dimensions
- [TODO] merge `func/metadata.py` with `func/images.py` and refactor
- [TODO] fix thumbnail generation
[server] `func/images.py`:
  - `Image` is now `Image` and `Video`, with their own post-type-specific
    operations; some of them from `func/metadata.py`. as a result, post
    type checking will need to be done outside of the classes
  - apply orientation to [fixed] thumbnail generation and image conversion
  - moved `_execute` to a global function; it now purely uses streams
    instead of tempfiles
  - `func/images.py::Video::to_mp4()` removed code that downscales resolution
    to an even number since ffmpeg does it automatically
  - use fstrings instead of .format and % in certain places
  - DEPRECATING FLASH FILES; there really is no place for them in a
    photo-oriented booru such as this. will slowly phase it out overtime.
    added an error message for it
  - changed EXIF orientation reference URL
[server] `func/posts.py`:
  - `update_post_content()`: updated to use `func/images.py`'s new
    features
- [server/migration] merge add_camera -> add_date_taken
- [server/migration] rename add_date_taken -> add_date_taken_and_camera
- [server/migration] add_date_taken_and_camera: iterate through posts in db
  instead of files
- [server] changed Post.camera from sa.Text -> sa.UnicodeText
- [server] improved stability of `func/images.py`
- [todo] will add migration that fixes image dimensions and regenerates
  thumbnails later
- [repo] updated `README.md` and `doc/INSTALL.md`
- [build] configure `server` and `client` to build locally
- [dist] updated `doc/example.env` to unique build info
also included immich link
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.

1 participant