tagatac / bagoup

Mac OS Messages export
GNU Affero General Public License v3.0
72 stars 4 forks source link

Improve HEIC conversion #16

Open tagatac opened 2 years ago

tagatac commented 2 years ago

Several possible routes here:

Three main benefits:

magick appears to be stable at the cost of adding another system dependency.

richardsprague commented 2 years ago

My conversion stalled in the middle with this error:

decode HEIC image: error reading "ftyp" box: got box type "$\x14Ex" instead

tagatac commented 2 years ago

Ah, yes, that could also stand to be a warning (just referencing the HEIC file in the PDF when the conversion fails). I'll make that change.

@richardsprague, the full error message should give you the name of the file that bagoup is trying to convert. A couple of questions:

richardsprague commented 2 years ago
  1. No, I cannot open the (PDF) file that bagoup created. Yes, I can open the HEIC file.
  2. Yes, magick conversion works correctly and I'm able to open and view the resulting JPG.

ERROR: export chats: chat file "messages-export/+1206xxxxxxx/iMessage;-;+1206xxxxxxx;;;SMS;-;+1206xxxxxxx.pdf" - message 16871: convert HEIC file "~/Library/Messages/Attachments/be/14/at_0_616F6C1C-C506-4589-95D2-90E0D81D186B/IMG_0321.HEIC" to JPG: decode HEIC image: error reading "ftyp" box: got box type "$\x14Ex" instead

tagatac commented 2 years ago

Thanks for that info. That's great that magick conversion works. It seems like this is probably the way to go for the issue in the OP.

Just to confirm, both the HEIF and JPG files are openable and look good in Preview?

richardsprague commented 2 years ago

Yes, both HEIC and the JPG converted by Magick are openable and look fine.

tagatac commented 2 years ago

Thanks! I think this anecdote gives enough motivation to abandon goheif when combined with its other issues

tagatac commented 2 years ago

Hmm, magick seems to add nearly 30 seconds to the run time when converting 57 images on my MacBook 😕

BAGOUP RESULTS:
Export folder: "testgoheif"
Export files written: 45
Chats exported: 48
Messages exported: 2154
Attachments referenced or embedded:
    application/octet-stream: 100
    image/png: 3
    image/jpeg: 76
    video/quicktime: 10
    image/gif: 1
    text/x-vlocation: 1
    application/vnd.apple.pkpass: 1
    text/vcard: 1
Attachments embedded:
    image/png: 3
    image/jpeg: 76
    image/gif: 1
Attachments missing (see warnings above): 0
HEIC conversions completed: 57
HEIC conversions failed (see warnings above): 0
Time elapsed: 2m32.104904275s
BAGOUP RESULTS:
Export folder: "testmagick"
Export files written: 45
Chats exported: 48
Messages exported: 2154
Attachments referenced or embedded:
    application/vnd.apple.pkpass: 1
    text/vcard: 1
    application/octet-stream: 100
    image/png: 3
    image/jpeg: 76
    video/quicktime: 10
    image/gif: 1
    text/x-vlocation: 1
Attachments embedded:
    image/png: 3
    image/jpeg: 76
    image/gif: 1
Attachments missing (see warnings above): 0
HEIC conversions completed: 57
HEIC conversions failed (see warnings above): 0
Time elapsed: 3m0.292278226s
tagatac commented 2 years ago

In light of the performance advantages of goheif over imagemagick, I'm going to stick with goheif. I migrated to tagatac/goheif in https://github.com/tagatac/bagoup/commit/1b3e86c04692e58fb9f83ad3070286f5424a3fce, which achieves goals 2 and 3 from the OP.

There is probably still room for stability improvement by either

PRs welcome

MikeRich88 commented 1 month ago

What about the sips command? It's only on Mac OS, but it's also guaranteed to exist.

It only supports HEIC on whatever OS version added HEIC though - but then it's unlikely* you'd have messages with HEIC images on an OS before that.

*Messages is stupid and I've gotten HEIC's before in this manner.

tagatac commented 1 month ago

I did not know about this command! When I created this issue, I was still trying to keep bagoup consistent across MacOS and Linux. However, they've since diverged when I added an Objective C program to parse the contents of the attributedBody column in the message table. It's definitely worth investigating the stability and performance of sips. Thanks for calling it out!