mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +00:00
94 lines
3 KiB
Markdown
94 lines
3 KiB
Markdown
|
# pict-rs 0.5.7
|
||
|
|
||
|
## Overview
|
||
|
|
||
|
pict-rs 0.5.7 adds support for generating blurhashes from images and includes a couple unrelated
|
||
|
fixes and tweaks.
|
||
|
|
||
|
### Features
|
||
|
|
||
|
- [Blurhash Endpoint](#blurhash-endpoint)
|
||
|
|
||
|
|
||
|
### Changes
|
||
|
|
||
|
- [File Path Changes](#file-path-changes)
|
||
|
- [Performance Improvements](#performance-improvements)
|
||
|
|
||
|
|
||
|
### Fixes
|
||
|
|
||
|
- [More Consistent Errors](#more-consistent-errors)
|
||
|
- [APNG Detection](#apng-detection)
|
||
|
|
||
|
|
||
|
## Upgrade Notes
|
||
|
|
||
|
There is a small repo format migration between 0.5.6 and 0.5.7. For sled it's simply opening a new
|
||
|
tree, for postgres it involves adding a new column to the hashes table. These changes will
|
||
|
automatically apply when launching pict-rs 0.5.7. Upgrading should be as simple as pulling a new
|
||
|
version of pict-rs.
|
||
|
|
||
|
|
||
|
## Descriptions
|
||
|
|
||
|
### Blurhash Endpoint
|
||
|
|
||
|
A new endpoint at `/image/blurhash` has been added for generating blurhashes from uploaded media. A
|
||
|
blurhash is a short string that encodes a few notable color values from an image that can be
|
||
|
reconstructed into a blurred approximation of the original image. Notably, blurhashes are used by
|
||
|
Mastodon to act as placeholders for sensitive media. For more information about blurhashes, see
|
||
|
[blurha.sh](https://blurha.sh).
|
||
|
|
||
|
This endpoint is powered by my new blurhash encoding library,
|
||
|
[blurhash-update](https://crates.io/crates/blurhash-update).
|
||
|
|
||
|
On success, the blurhash endpoint returns the following JSON.
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"msg": "ok",
|
||
|
"blurhash": "LGF5]+Yk^6#M@-5c,1J5@[or[Q6."
|
||
|
}
|
||
|
```
|
||
|
|
||
|
pict-rs does not provide a blurhash decoding mechanism (it would defeat the purpose of blurhashes to
|
||
|
do so).
|
||
|
|
||
|
|
||
|
### File Path Changes
|
||
|
|
||
|
pict-rs has dropped its dependency on my `storage-path-generator` library in favor of using UUIDs to
|
||
|
create unique file paths for uploaded media. This means that newly uploaded media will be stored in
|
||
|
a different directory structure, and with different filenames. The purpose of this is to reduce
|
||
|
database use by removing the need to synchronize the current path state.
|
||
|
|
||
|
pict-rs 0.5.7 also adds file extensions back to file paths, since they are now somewhat-publicly
|
||
|
visible (when using the public_endpoint configuration with object storage).
|
||
|
|
||
|
Neither of these changes affect previously uploaded media.
|
||
|
|
||
|
|
||
|
### Performance Improvements
|
||
|
|
||
|
pict-rs 0.5.7 now buffers media in memory less frequently, opting to stream bytes directly from
|
||
|
sources to sinks. This should improve general memory use, as well as decrease time pict-rs would
|
||
|
spend waiting to aggregate bytes.
|
||
|
|
||
|
pict-rs also no longer requires bytes be present in contiguous buffers, avoiding large allocations
|
||
|
and reducing memcpys.
|
||
|
|
||
|
|
||
|
### More Consistent Errors
|
||
|
|
||
|
pict-rs 0.5 introduced machine-readable error codes that returned alongside error messages, but
|
||
|
there were a couple locations in pict-rs that failed to include them. pict-rs 0.5.7 resolves this,
|
||
|
ensuring all error paths properly return codes.
|
||
|
|
||
|
|
||
|
### APNG Detection
|
||
|
|
||
|
pict-rs 0.5.7 fixes the imagemagick delegate policy for ffmpeg, which allows for properly detecting
|
||
|
certain media, notably APNG files. pict-rs should once again be able to properly handle uploaded
|
||
|
APNGs.
|