Commit Graph

50 Commits (d4e7948a2fd41ff04e6dbb3020297bc5bac4ddde)

Author SHA1 Message Date
Your Name b6d645a4d4 fix: delete superseded image/thumbnail files instead of orphaning them
Image::handleImageTransform derives the output filename from the current
media_path and applies the encoder's output extension. When that differs from
what is already stored (heic/avif -> jpg, or a thumbnail regenerated to a new
extension), the new file landed at a different path and the previous file was
left orphaned in the media directory — the source of the leftover _thumb files
under public/m/_v2.

Capture the path each transform supersedes and delete it after a successful
write (only when the new output path differs, so we never delete what we just
wrote). Remove the stale MediaDeleteLeafCleanupTest whose source change is not
in the tree.
4 weeks ago
Shlee 79af98f9d0
Merge pull request #6667 from vinzgreg/fix/blurhash-memory-strands-video-uploads
Fix videos never reaching cloud storage by downscaling in Blurhash (#2652)
4 weeks ago
Your Name c0cde2f682 refactor: move 52 legacy models from App\ to App\Models\
Move all Eloquent models from the app/ root directory to app/Models/
for consistency with modern Laravel conventions. The project already had
54 models in App\Models; this migrates the remaining 52 legacy models.

Changes:
- Move 52 model files from app/ to app/Models/
- Update namespace declarations in each model
- Update all ~1000 import references across the codebase
- Add Relation::morphMap() in AppServiceProvider for backward
  compatibility with existing polymorphic database records
- Add missing HasSnowflakePrimary imports for models that relied
  on same-namespace resolution
1 month ago
Daniel Supernault 33dce75f2c
Pint app/ 1 month ago
Your Name c807a8524c refactor: replace short facade aliases with fully-qualified imports
Convert all 273 short facade alias imports (e.g. 'use Cache;') to their
fully-qualified class names (e.g. 'use Illuminate\Support\Facades\Cache;')
across 193 files.

This resolves 643 PHPStan 'class.notFound' errors caused by the static
analyzer being unable to resolve global aliases, and aligns with modern
Laravel conventions. It also unblocks removing the aliases array from
config/app.php in a future change.

All 107 tests pass.
1 month ago
Shlee 2e97341e0d
Merge branch 'staging' into fix/exif-orientation-portrait-photos 1 month ago
Your Name 552a55c2d2 Upgrade images to v4 1 month ago
vinz ef56880a74 Fix videos never reaching cloud storage by downscaling in Blurhash
Blurhash::generate() allocates one PHP array per pixel of the source. At
roughly 255 bytes per pixel (measured: 224 MB peak for a 720x1280 frame) a
1920x1080 frame approaches half a gigabyte.

Image thumbnails survive this because they are capped at 640x640 in
Image::__construct() *and* run under that constructor's
ini_set('memory_limit', '1024M'). Video thumbnails get neither: FFmpeg saves
them at the source video's resolution, and VideoThumbnail never raises the
limit. So a video whose frame is 1080p or larger exhausts memory_limit.

That is a PHP fatal, not an \Exception, which has three consequences:

  - the catch block in VideoThumbnail::handle() does not catch it
  - the job never lands in failed_jobs, so nothing reports a problem
  - MediaStoragePipeline::dispatch() on the last line of handle() never runs

The video therefore stays on local disk permanently while images beside it
replicate normally. Reported in #2652 (2021-02-13) and diagnosed correctly in
that thread on 2021-11-04.

Two changes:

1. Blurhash::generate() downscales to 128px on the long edge before sampling.
   The result is a 4x4-component DCT, so full-resolution sampling adds
   essentially nothing: measured against the full-resolution hash, mean
   per-channel deviation of the decoded 24x24 preview is ~7.5/255 at a 32px
   sample, ~4.5/255 at 64px, ~2.5/255 at 128px, and no better at 256px. Peak
   memory for the frame above drops from 224 MB to 6 MB.

   This removes the ceiling for every caller rather than moving it, which is
   all that raising memory_limit would have done. Existing stored hashes are
   not recomputed, so nothing already published changes appearance.

2. VideoThumbnail wraps the blurhash in its own try/catch, so a decorative
   step can no longer skip the replication dispatch. Change 1 covers the
   fatal; this covers any ordinary exception.

Verified on a live instance with S3 cloud storage: a 1920x1080 video that
previously stranded now generates a blurhash, uploads original and thumbnail
to the bucket, sets cdn_url/thumbnail_url/replicated_at, and removes the local
copies. Existing images re-hash to visually identical previews.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2 months ago
Stefan 4f13ebfe3f fix: apply EXIF orientation before resizing portrait images
Smartphone photos stored in landscape orientation with an EXIF rotation
tag were being saved to S3 in the wrong orientation. Image.php read the
raw pixel dimensions without first applying the EXIF tag, so portrait
photos (e.g. 4032×3024 with Orientation=6) were classified and resized
as landscape (1920×1080).

Calling orient() immediately after read() physically rotates the image
to match its EXIF orientation tag before any dimension checks or
scaling. This ensures portrait photos remain portrait after processing.

Intervention Image v3 reference:
https://image.intervention.io/v3/modifying/orientation
4 months ago
Your Name 89c54bbd84 bad logic 8 months ago
Shlee 649d31bd32
Update Image.php 9 months ago
Daniel Supernault 53742fa699
Lint 9 months ago
Shlee d3ecf22895
Update Image.php 11 months ago
Shlee b579d93cad
Create ImageDriverManager.php 11 months ago
Daniel Supernault 2e719bd008
Update media storage pipeline, improve support for non-local filesystems 1 year ago
Daniel Supernault 4e938a8ffa
Fix heic, avif, webp support and add libvips driver 1 year ago
Daniel Supernault 86bb81d1a9
Fix typo 1 year ago
Daniel Supernault 5c7064063d
Typo 1 year ago
Daniel Supernault ab9c13fe0d
New supported formats, Preserve ICC Color Profiles, libvips support
Update image pipeline to handle avif, heic and webp and preserve ICC color profiles and added libvips support.
1 year ago
Daniel Supernault 1a9a0da37d
Update Image.php 2 years ago
Emelia Smith 74ad26fee6
Fix potential memory leak due to not calling imagedestroy on GdImage objects 3 years ago
Daniel Supernault 2642f9d7af
Update filter name 4 years ago
Daniel Supernault b1f47e76ff
Rename filters 4 years ago
daniel c43f9ab7a4
Update app/Util/Media/Image.php
Co-authored-by: Daniel Mason <daniel@m2.nz>
5 years ago
Jonathan 27b715cb35
Avoid upscaling small images 5 years ago
Daniel Supernault f6131ed764
Update License util, add nameToId method 5 years ago
Daniel Supernault 069a0e4ae1
Add WebP support 5 years ago
Daniel Supernault a9f009305c
Update config() to config_cache() 5 years ago
Daniel Supernault 552e950d7a
New License formats 6 years ago
Daniel Supernault 38a37c15af
Update Blurhash util, add default hash for invalid media 6 years ago
Daniel Supernault 40bd64aae7
Update Image media util, store dimensions of media not thumbnail 6 years ago
Daniel Supernault 473e049528
Update media pipeline, add blurhash support 6 years ago
Daniel Supernault 9404a36c66
Add Blurhash util 6 years ago
Daniel Supernault d63569c120
Add Direct Messages 6 years ago
Daniel Supernault 0b7c5d6d37
Update Image Util 7 years ago
Daniel Supernault 7355e94723
Update Image Util 7 years ago
Daniel Supernault 3d53661b18
Update Image util 7 years ago
Daniel Supernault bd7cad9984
Update Image util 7 years ago
Daniel Supernault 25d632c761
Add new config 7 years ago
Daniel Supernault 063277d3e2
Add Filter util 8 years ago
Daniel Supernault e2707ba174
Update Image util 8 years ago
Daniel Supernault a14532e715
Fixes #578 8 years ago
Daniel Supernault 46fdcf0718
Update Image util 8 years ago
Daniel Supernault 84d1e3b731
Update thumbnail logic 8 years ago
daniel b8abbdd90f Apply fixes from StyleCI 8 years ago
Daniel Supernault 774557e8c9
Add custom image quality to config 8 years ago
Daniel Supernault 56b18f3e08 Update ImageOptimizePipeline, do not optimize gifs 8 years ago
Daniel Supernault b437b62780 Update Image class, remove PNG -> JPEG conversion and use orientate() method to detect proper orientation in Exif 8 years ago
Daniel Supernault e94d9534b1 Fix image resizing logic 8 years ago
Daniel Supernault e3590c3768 Add Image Util class 8 years ago