Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-colorspace Gray on HEIC image produces corrupted file #6918

Open
Anicky opened this issue Dec 5, 2023 · 9 comments
Open

-colorspace Gray on HEIC image produces corrupted file #6918

Anicky opened this issue Dec 5, 2023 · 9 comments

Comments

@Anicky
Copy link

Anicky commented Dec 5, 2023

ImageMagick version

7.1.1-13

Operating system

Linux

Operating system, version and so on

Alpine 3.18.5

Description

When upgrading ImageMagick from version 7.1.0-16 to 7.1.1-13, our command to compress HEIC image and set colorspace to gray doesn't work anymore. It produces a corrupted file. Moreover, the process time is 6 times slower than before.

Before :

$ cat /etc/os-release

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.15.6
PRETTY_NAME="Alpine Linux v3.15"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

$ magick --version

Version: ImageMagick 7.1.0-16 Q16-HDRI x86_64 2021-11-21 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jng jpeg lcms ltdl lzma png ps rsvg tiff webp x xml zlib
Compiler: gcc (10.3)

$ time magick convert -quality 50 -colorspace Gray image.heic new1.heic

real    0m2.156s
user    0m23.128s
sys     0m0.251s

After :

$ cat /etc/os-release

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.18.5
PRETTY_NAME="Alpine Linux v3.18"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

$ magick --version

Version: ImageMagick 7.1.1-13 Q16-HDRI x86_64 21276 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jng jpeg jxl lcms ltdl lzma png ps raw rsvg tiff webp x xml zlib
Compiler: gcc (12.2)

$ time magick convert -quality 50 -colorspace Gray image.heic new2.heic

real    0m11.927s
user    0m12.242s
sys     0m0.151s

The original image (image.heic) and the generated files (before : new1.heic, after : new2.heic) are attached below in a zip file.

Steps to Reproduce

magick convert -quality 50 -colorspace Gray image.heic new.heic

Images

images.zip

@fmw42
Copy link

fmw42 commented Dec 5, 2023

On IM 7, you should use magick, not magick convert.

@Anicky
Copy link
Author

Anicky commented Dec 5, 2023

Thank you for this information, I didn't know that!

Unfortunately, I just tried this command with same parameters than before and result is the same.

$ time magick image.heic -quality 50 -colorspace Gray new2.heic

real    0m12.143s
user    0m12.469s
sys     0m0.150s

The process is very slow (12s compared to 2s) and it produces a corrupted image.

@fmw42
Copy link

fmw42 commented Dec 5, 2023

On my M1 Mac with 8GB RAM and IM 7.1.1.22 and libheif 1.15.2, I get

time magick image.heic -quality 50 -colorspace Gray new2.heic

real	0m4.149s
user	0m26.823s
sys	0m0.127s

The result looks fine.

new2.heic.zip

@Anicky
Copy link
Author

Anicky commented Dec 6, 2023

Could this be a problem related to Alpine?

Or libheif maybe?

@fmw42
Copy link

fmw42 commented Dec 6, 2023

What is your version of libheif?

@Anicky
Copy link
Author

Anicky commented Dec 6, 2023

The version of installed libheif package is: 1.16.2r-0:

$ apk version libheif
Installed:                                Available:
libheif-1.16.2-r0                       = 1.16.2-r0

@fmw42
Copy link

fmw42 commented Dec 6, 2023

Look for it in

magick -list format

for example I have

HEIF HEIC rw+ High Efficiency Image Format (1.15.2)

@Anicky
Copy link
Author

Anicky commented Dec 6, 2023

Here is what I have:

$ magick -list format | grep HEIF
     HEIF  HEIC      rw+   High Efficiency Image Format (1.16.2)

@fmw42
Copy link

fmw42 commented Dec 6, 2023

That version should be fine unless it has a bug. It worked fine for me on my Mac with 1.15.2.

IM 7.1.1-13 is a bit old. Perhaps it had a bug. Try upgrading to the current version.

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

No branches or pull requests

2 participants