Incorrect APP1 Exif Identifier files:scan

Nextcloud version (eg, 20.0.5):
Operating system and version (eg, Ubuntu 20.04): Debian 12.4.0 (VM on Proxmox)
nginx version (eg, Apache 2.4.25): 1.22.1-9
PHP version (eg, 7.4): 8.2+93+0~20231125.47

The issue you are facing:
When importing high resolution photos taken by Nikon Camera and edited with Photoshop I’m not able to get the EXIF Metadata.
I uploaded all the photos via scp to an folder in username/files/Photos/
I chown the folder as well as the files to www-data.
Then i ran
sudo -u www-data /usr/bin/php /opt/nextcloud/occ files:scan --path="username/files/Photos/myfolder"
sudo -u www-data /usr/bin/php /opt/nextcloud/occ files:scan --path="username/files/Photos/myfolder" --generate-metadata
This command throws an error for each file:

Error during scan: exif_read_data(): Incorrect APP1 Exif Identifier Code

and ends with:

| Folders | Files | New | Updated | Removed | Errors | Elapsed time |
| 1       | 409   | 0   | 0       | 0       | 409    | 00:00:16     |

I was easily able to use exiftool to verify, that the metadata is actually fine. But occ wont recognize and always throws this error.
Without the metadata properly set in Nextcloud, the pictures are not shown on the map nor are they sorted properly in the timeline. Any help would be appreciated.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. see above

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'passwordsalt' => 'frischesmeersalz',
  'secret' => 'asecret',
  'trusted_domains' =>
  array (
    0 => 'my.private.domain'
  'datadirectory' => '/var/ncdata',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'https://my.private.domain',
  'dbname' => 'nextcloud',
  'dbhost' => '',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'auser',
  'dbpassword' => 'safepassword',
  'installed' => true,
  'instanceid' => 'anID',
  'default_phone_region' => 'DE',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'open_basedir' => '/dev/urandom',
  '' => 'production',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => '0',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'app_install_overwrite' =>
  array (
    0 => 'memories',
    1 => 'bookmarks_fulltextsearch',
    2 => 'files_fulltextsearch_tesseract',
  'memories.exiftool' => '/opt/nextcloud/apps/memories/bin-ext/exiftool-amd64-glibc',
  'memories.vod.path' => '/opt/nextcloud/apps/memories/bin-ext/go-vod-amd64',
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\Image',
    1 => 'OC\\Preview\\HEIC',
    2 => 'OC\\Preview\\TIFF',
    3 => 'OC\\Preview\\Movie',
  'preview_max_x' => 2048,
  'preview_max_y' => 2048,
  'memories.gis_type' => 1,

Has anyone any idea? Help would be greatly appreciated.

Well, you were right that it doesn’t like something about the information after your edit. With the message, you find a few references to other php solutions. For this case, if there is no obvious problem with the exif information, I’d consider creating a bug report Issues · pulsejet/memories · GitHub
If you can provide example files, that would be great (some small image, before edit where it works, and after edit where it doesn’t work).

Since these are Photos from a professional I dont have the originals But I will try to get some.

Isnt that exif scan something from nextcloud directly?

Perhaps try just a small picture from your smartphone. It seems to be the editing changing the thing.

It is through this memories app as far as I have seen, but there are perhaps other ways as well, do you have it enabled?

There was a metadata app as well (only supported until NC27 so far), perhaps interesting if they manage to read it. They need to add support for NC 28: Add Nextcloud 28.x Compatibility. · Issue #105 · gino0631/nextcloud-metadata · GitHub

So I have clarified with the developers from pulsejet.
They clarified files:scan --generate-metadata is not made by them. So this is a NextCloud issue.

Can anyone help me out?

I have the original now. NEF file. It has the full metadata and gets scanned no problem.
The photographer told me they simply removed the information about the camera.

I still dont understand how exiftool reads this without any issues and file:scan cant.

I found it being used in:

In case that is the same location, it would be the main repository responsible for this part of the code.

The underlying function to extract the EXIF information seems to be the function exif_read_data() directly implemented in PHP.

On the php documentation, they mention a specification, so you are sure your metadata fits the specification?

I am clueless, what the right tags would be or which ones are missing.
This EXIF Tags
does list a huge amount of tags.

Not sure which one is required to get the php function working.
A shame it is not as robust as exiftool is.

Guess I will have to ask the photographer, if he can export without stripping some tags.

If you can provide a file that works and one that doesn’t work? Just a small test image?