MaestroError / php-heic-to-jpg

The easiest way to convert HEIC images to JPEG with PHP and Laravel framework
MIT License
148 stars 20 forks source link

Works on some images and errors with others #7

Closed hooverweb closed 1 year ago

hooverweb commented 1 year ago

Hi @MaestroError - I'm having a problem with some HEIC images (about half) giving an error while converting. Then, other HEIC images convert without issue. It's the image itself that determines if it fails or not. Any image that fails to convert will keep failing when I try again.

Sample files: works.heic fails.heic

Error: Fatal error: Uncaught RuntimeException: Couldn't convert HEIC to JPG: '' | Bin used: 'heicToJpg' HEIC: '/var/www/example.com/public_html/content/images/temp/fails.heic' Full Command: '/var/www/composer/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg /var/www/example.com/public_html/content/images/temp/fails.heic /var/www/example.com/public_html/content/images/temp/fails.heic-181417596641365983cec09.38828464' in /var/www/composer/vendor/maestroerror/php-heic-to-jpg/src/HeicToJpg.php:139 Thanks

MaestroError commented 1 year ago

Hi @hooverweb ! Thank you for reaching me out, I am not sure what is a problem. I had similar issue only with images, which weren't a original HEIC format (for example, converted to HEIF from JPG/PNG/WebP), sounds this case like yours?

hooverweb commented 1 year ago

That could be the case. I don't use Apple products, so I'm just using test images that I found online. Just out of curiosity, does the "fails.heic" image that's linked above also fail when you try to convert it?

MaestroError commented 1 year ago

Not sure yet, I will test it when I get a time and come back to you 👍

MaestroError commented 1 year ago

@hooverweb Yes, here is the same error. I tried it directly with Go and get this error heif: no EXIF found. As it seems, we got here bad-formated file, but I don't know how to handle it yet

MaestroError commented 1 year ago

I was able to skip EXIF data, if it does not exist and write JPEG without it, but anyway it gives a broken image (1kb) and this huge error:

# Command: go run .\main.go "fails.heic" "fails.heic.jpeg"
# Just logs an EXIF error: 2023/03/17 21:29:00 heif: no EXIF found
# And continues with this: 
unexpected fault address 0x20efe55f050
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0x20efe55f050 pc=0x7ff76e939adc]

goroutine 1 [running]:
runtime.throw({0x7ff76eaa2e9e?, 0x0?})
        C:/Program Files/Go/src/runtime/panic.go:1047 +0x65 fp=0xc00007f340 sp=0xc00007f310 pc=0x7ff76e8c4f05
runtime.sigpanic()
        C:/Program Files/Go/src/runtime/signal_windows.go:270 +0xd0 fp=0xc00007f388 sp=0xc00007f340 pc=0x7ff76e8d6c90
image/jpeg.yCbCrToYCbCr(0xc000120100, {0x7ff76ea62750?, 0x0?}, 0xc00007f490, 0xc00007f990, 0xc00007f590)
        C:/Program Files/Go/src/image/jpeg/writer.go:461 +0x17c fp=0xc00007f408 sp=0xc00007f388 pc=0x7ff76e939adc
image/jpeg.(*encoder).writeSOS(0xc0000000c0, {0x7ff76eac9ce8?, 0xc000120100?})
        C:/Program Files/Go/src/image/jpeg/writer.go:547 +0x485 fp=0xc00007fdc0 sp=0xc00007f408 pc=0x7ff76e93a145
image/jpeg.Encode({0x7ff76eac9928?, 0xc0000091d0?}, {0x7ff76eac9ce8, 0xc000120100}, 0x0)
        C:/Program Files/Go/src/image/jpeg/writer.go:634 +0x33f fp=0xc00007fe38 sp=0xc00007fdc0 pc=0x7ff76e93a5bf
main.convertHeicToJpg({0xc0000160d0?, 0x7ff76e8eb3a5?}, {0xc000016100, 0xf})
        C:/Users/XPS/Desktop/php-heic-to-jpg/main.go:68 +0x1a6 fp=0xc00007fef8 sp=0xc00007fe38 pc=0x7ff76e94b726
main.main()
        C:/Users/XPS/Desktop/php-heic-to-jpg/main.go:22 +0x3e fp=0xc00007ff80 sp=0xc00007fef8 pc=0x7ff76e94b43e
runtime.main()
        C:/Program Files/Go/src/runtime/proc.go:250 +0x1f7 fp=0xc00007ffe0 sp=0xc00007ff80 pc=0x7ff76e8c7677
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00007ffe8 sp=0xc00007ffe0 pc=0x7ff76e8efac1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:381 +0xd6 fp=0xc000049fb0 sp=0xc000049f90 pc=0x7ff76e8c7a96
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:387
runtime.forcegchelper()
        C:/Program Files/Go/src/runtime/proc.go:305 +0xb2 fp=0xc000049fe0 sp=0xc000049fb0 pc=0x7ff76e8c78b2
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000049fe8 sp=0xc000049fe0 pc=0x7ff76e8efac1
created by runtime.init.6
        C:/Program Files/Go/src/runtime/proc.go:293 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:381 +0xd6 fp=0xc00004bf80 sp=0xc00004bf60 pc=0x7ff76e8c7a96
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
        C:/Program Files/Go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc00004bfc8 sp=0xc00004bf80 pc=0x7ff76e8b26ae
runtime.gcenable.func1()
        C:/Program Files/Go/src/runtime/mgc.go:178 +0x26 fp=0xc00004bfe0 sp=0xc00004bfc8 pc=0x7ff76e8a7ae6
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00004bfe8 sp=0xc00004bfe0 pc=0x7ff76e8efac1
created by runtime.gcenable
        C:/Program Files/Go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000054000?, 0x7ff76eac80a8?, 0x1?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:381 +0xd6 fp=0xc00005bf70 sp=0xc00005bf50 pc=0x7ff76e8c7a96
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x7ff76eb88180)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc00005bfa0 sp=0xc00005bf70 pc=0x7ff76e8b05d3
runtime.bgscavenge(0x0?)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc00005bfc8 sp=0xc00005bfa0 pc=0x7ff76e8b0bc5
runtime.gcenable.func2()
        C:/Program Files/Go/src/runtime/mgc.go:179 +0x26 fp=0xc00005bfe0 sp=0xc00005bfc8 pc=0x7ff76e8a7a86
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005bfe8 sp=0xc00005bfe0 pc=0x7ff76e8efac1
created by runtime.gcenable
        C:/Program Files/Go/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x1a0?, 0x7ff76eb885c0?, 0xa0?, 0x6e?, 0xc00004df70?)
        C:/Program Files/Go/src/runtime/proc.go:381 +0xd6 fp=0xc00004de28 sp=0xc00004de08 pc=0x7ff76e8c7a96
runtime.runfinq()
        C:/Program Files/Go/src/runtime/mfinal.go:193 +0x107 fp=0xc00004dfe0 sp=0xc00004de28 pc=0x7ff76e8a6b47
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00004dfe8 sp=0xc00004dfe0 pc=0x7ff76e8efac1
created by runtime.createfing
        C:/Program Files/Go/src/runtime/mfinal.go:163 +0x45
exit status 2
hooverweb commented 1 year ago

Ok, It sounds like it might not be too big of a real-world problem, if it's only previously converted images that are causing the issue. Thanks for checking!