Skip to content

Index: Log underlying error when MIME type detection fails #5149

Description

@drewp

Many photos from my Nikon 5000 SLR camera are plain JPEG files, not JFIF files. This appears to fail to ingest with a misleading error message. Either the error message should be improved or, ideally, the support should be fixed.

Repro

Run docker.io/photoprism/photoprism:250707 in k8s on linux x86_64.

Make a test dir like this:

/my/pic/jpeg-test% l
total 8711
-rw-rw-r-- 1 drewp drewp    7298 Aug  4 21:07 jfif2.jpg
-rw------- 1 drewp drewp 4355064 Aug  4 21:04 plain.jpg
-rw------- 1 drewp drewp 4355064 Aug  4 21:03 plain.JPG

Run the file command:

/my/pic/jpeg-test% file *
jfif2.jpg: JPEG image data, JFIF standard 1.01, resolution (DPCM), density 39x39, segment length 16, baseline, precision 8, 235x64, components 1
plain.jpg: JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=11, manufacturer=NIKON CORPORATION, model=NIKON D5000, orientation=upper-left, xresolution=180, yresolution=188, resolutionunit=2, software=Ver.1.00 , datetime=2009:07:31 01:52:34, GPS-Data], baseline, precision 8, 4288x2848, components 3
plain.JPG: JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=11, manufacturer=NIKON CORPORATION, model=NIKON D5000, orientation=upper-left, xresolution=180, yresolution=188, resolutionunit=2, software=Ver.1.00 , datetime=2009:07:31 01:52:34, GPS-Data], baseline, precision 8, 4288x2848, components 3

Run ffprobe:

/my/pic/jpeg-test% ffprobe -hide_banner plain.jpg 
Input #0, image2, from 'plain.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 871012 kb/s
  Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 4288x2848, 25 fps, 25 tbr, 25 tbn

See the mounted files from inside the k8s container:

photoprism@250707:/photoprism/originals/jpeg-test$ ls -ll
ls: plain.JPG: Permission denied
ls: plain.jpg: Permission denied
total 8711
-rw-rw-r-- 1 user-501 photoprism    7298 Aug  5 04:07 jfif2.jpg
-rw------- 1 user-501 photoprism 4355064 Aug  5 04:03 plain.JPG
-rw------- 1 user-501 photoprism 4355064 Aug  5 04:04 plain.jpg

On the PP web ui, reindex /jpeg-test. The logs follow:

1  level=info msg="indexing completed in 286 s"
2  level=info msg="indexing files in jpeg-test"
3  level=debug msg="exiftool: extracting metadata from jpeg-test/jfif2.jpg"
4  level=debug msg="cache: created b47fe917f2b1593d5eafe5877fed947769be406a_exiftool.json"
5  level=warning msg="index: skipped jpeg-test/plain.JPG because it has an invalid extension (unknown media type)"
6  level=warning msg="index: skipped jpeg-test/plain.jpg because it has an invalid extension (unknown media type)"
7  level=info msg="media: generated 8 thumbnails for jpeg-test/jfif2.jpg [98.181021ms]"
8  level=info msg="media: jfif2.jpg was taken at 2025-08-05 04:07:57 +0000 UTC (file mod time)"

Log line 5 tricked me into thinking there was case sensitivity on the filenames, but I no longer think that's the issue.

However, it also doesn't seem to be the upstream mimetype lib's fault. Here's a result from https://github.com/gabriel-vasile/mimetype :

go mod init example
go get github.com/gabriel-vasile/mimetype
% cat go.mod
module example

go 1.24.2

require (
	github.com/gabriel-vasile/mimetype v1.4.9 // indirect
	golang.org/x/net v0.39.0 // indirect
)

main.go

package main

import (
	"fmt"
	"os"

	"github.com/gabriel-vasile/mimetype"
)

func main() {
	filePath := os.Args[1]
	file, _ := os.Open(filePath)
	mime, _ := mimetype.DetectReader(file)
	fmt.Printf("The MIME type of the file is: %s\n", mime.String())
}

Output:

% go run main.go /my/pic/jpeg-test/jfif2.jpg 
The MIME type of the file is: image/jpeg

% go run main.go /my/pic/jpeg-test/plain.jpg     
The MIME type of the file is: image/jpeg

% go run main.go /my/pic/jpeg-test/plain.JPG
The MIME type of the file is: image/jpeg

% go run main.go /etc/passwd                
The MIME type of the file is: text/plain; charset=utf-8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

metadataRelated to Exif, XMP, IPTC & Co.releasedAvailable in a stable releasesetupDocker images, Helm charts, scripts, and Compose examplesuxImpacts User Experience

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions