ReagentX / imessage-exporter

Export iMessage data + run iMessage Diagnostics
GNU General Public License v3.0
3.03k stars 130 forks source link

Image conversion not working on Windows #318

Closed amarcolini closed 3 months ago

amarcolini commented 3 months ago

(Slightly unrelated) I think for non-Mac users it would be beneficial to note that ImageMagick is required for image conversion somewhere in the documentation (or maybe the error messages). Also, maybe check for ImageMagick v7 before legacy versions. Windows has its own "convert" command that may get confused for ImageMagick. Another fix could be to make sure the convert command isn't in System32.

Attempting to export an iOS message database using -c compatible on Windows yielded these errors:

This doesn't seem to have to do with ImageMagick at all, since it doesn't change the behavior of the program

ReagentX commented 3 months ago

An error like The system cannot find the file specified suggests that the files may be missing, not that the converter is causing the problem.

Can you share more about your platform and how you are running imessage-exporter? What is the output of imessage-exporter -d?

amarcolini commented 3 months ago

Here is the output for -d:

Handle diagnostic data:
    Contacts with more than one ID: 8
Message diagnostic data:
    Total messages: 140685
    Messages not associated with a chat: 3
Attachment diagnostic data:
    Total attachments: 7485
        Data referenced in table: 7.81 GB
        Data present on disk: 6.41 GB
    Missing files: 1010 (13%)
        No path provided: 1
        No file located: 1009
Global diagnostic data:
    Total database size: 40.00 KB
    Duplicated contacts: 32
    Duplicated chats: 6

I will also note that on version 1.9.0 of the CLI this issue doesn't occur, and regardless of whether ImageMagick is present imessage-exporter outputs "No HEIC converter found". I believe version 2.0.1 fixed finding executables on the system path for Windows, but it finds the built-in Windows convert, leading to the first two error messages. I still don't understand the last one, because running where convert outputs:

C:\Program Files\ImageMagick-6.9.13-Q16-HDRI\convert.exe
C:\Windows\System32\convert.exe

I'm using the latest version of the imessage-exporter CLI on Windows 11.

ReagentX commented 3 months ago

Thank you for the details, I will look into this.

amarcolini commented 3 months ago

Ok I seem to have found something. This answer points out that some Windows API for creating command processes checks System32 before the PATH variable, which would give the system convert priority over ImageMagick's. It could be that Rust uses this API internally to call commands.

ReagentX commented 3 months ago

There indeed is some platform specific behavior here. See: #37519.

Given the name collision, I may need to remove the legacy support altogether.

amarcolini commented 3 months ago

I can confirm the name collision. Renaming the Windows convert utility to something else causes image conversion to work as normal. All .heif and .heic files are converted to .jpeg (.mov files stay the same).