termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.29k stars 3.06k forks source link

[Bug]: ImageMagick 7.1.1-23 fails to open (most) images #18740

Closed AgentConDier closed 10 months ago

AgentConDier commented 10 months ago

Problem description

For some image files, magick will fail to open them:

~ $ magick --version
Version: ImageMagick 7.1.1-23 Q16-HDRI aarch64 21803 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI
Delegates (built-in): bzlib cairo fftw fontconfig freetype heic jng jp2 jpeg jxl lcms lzma openexr pangocairo png rsvg tiff webp x xml zlib zstd
Compiler: gcc (4.2)
~ $ magick identify test.jpg
identify: unable to read image data `test.jpg' @ error/constitute.c/ReadImage/991.
~ $ wget https://termux.dev/assets/globals/hosts/hosted-by-hetzner.png
[…]
2023-12-18 06:56:57 (33.7 MB/s) - ‘hosted-by-hetzner.png’ saved [4159/4159]

~ $ magick identify hosted-by-hetzner.png
identify: unable to read image data `hosted-by-hetzner.png' @ error/constitute.c/ReadImage/991.

One image that does work are the PNGs generated by adb shell screencap:

~ $ adb shell screencap -p > test.png
~ $ magick identify test.png
test.png PNG 1440x3120 1440x3120+0+0 8-bit sRGB 449713B 0.000u 0:00.000

What steps will reproduce the bug?

~ $ magick logo: test.png
~ $ magick identify test.png
identify: unable to read image data `test.png' @ error/constitute.c/ReadImage/991.

What is the expected behavior?

ImageMagick is able to read and process the image

~ $ magick identify test.png
test.png PNG 1440x3120 1440x3120+0+0 8-bit sRGB 449713B 0.000u 0:00.000

System information

termux-info:

Termux Variables:
TERMUX_API_APP__VERSION_NAME=0.50.1
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__AM_SOCKET_SERVER_ENABLED=true
TERMUX_APP__APK_PATH=/data/app/com.termux-zkT9dbkDCahleTs21dOoaQ==/base.apk
TERMUX_APP__APK_RELEASE=GITHUB
TERMUX_APP__FILES_DIR=/data/user/0/com.termux/files
TERMUX_APP__IS_DEBUGGABLE_BUILD=true
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_MANAGER=apt
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PACKAGE_VARIANT=apt-android-7
TERMUX_APP__PID=10675
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c213,c257,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_APP__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c213,c257,c512,c768
TERMUX_APP__TARGET_SDK=28
TERMUX_APP__UID=10469
TERMUX_APP__USER_ID=0
TERMUX_APP__VERSION_CODE=118
TERMUX_APP__VERSION_NAME=0.118.0+1488bb0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0+1488bb0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://md.mirrors.hacktegic.com/termux/termux-main stable main
# sources.list.d/rendiix.list
deb https://rendiix.github.io android-tools termux
# x11-repo (sources.list.d/x11.list)
deb https://md.mirrors.hacktegic.com/termux/termux-x11 x11 main
Updatable packages:
All packages up to date
termux-tools version:
1.39.6
Android version:
10
Kernel build information:
Linux localhost 4.14.116 #1 SMP PREEMPT Mon May 16 11:02:17 CST 2022 aarch64 Android
Device manufacturer:
HUAWEI
Device model:
LYA-L29
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
helpimnotdrowning commented 10 months ago

I thought I was going insane since seemingly no one else was having this issue...

Images downloaded from the internet seem to work, but images created by Tasker's Crop function and ffmpeg don't load at all. I'm able to work with them on Windows, howvever.

Example broken image (assuming github upload doesn't reencode it): taskerout

AgentConDier commented 10 months ago

Yup, that one doesn't work for me either.

~ $ magick identify image.png 
identify: unable to read image data `image.png' @ error/constitute.c/ReadImage/991.
~ $ md5sum image.png 
48f5939bc1200e150101272167f60138  image.png

Displays fine using timg though.

Suletta-Majo commented 10 months ago

I don't know if it's related, but it's also my trouble. I can't use chafa, which I was able to use until yesterday. I wonder if it's because I've updated the area around ImageMagick with PKG I came here looking for similar trouble information searching

[~/pyprog]$ chafa
CANNOT LINK EXECUTABLE "chafa": library "libOpenEXR-3_2.so" not found: needed by
/data/data/com.termux/files/usr/lib/libMagickWand-7.Q16HDRI.so in namespace (default)

[~/pyprog]$ python3 plottwo.py
Traceback (most recent call last):
  File "/data/data/com.termux/files/home/pyprog/plottwo.py", line 3, in <module>
    from chafa.loader import Loader
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/chafa/loader.py", line 64, in <module>
    raise ImportError("MagickWand library not found.")
ImportError: MagickWand library not found.
twaik commented 10 months ago

Seems like it was broken during updates. Can you please remind me to trigger rebuild in 8 hours?

sylirre commented 10 months ago

@twaik I tried to rebuild it but that didn't solve the issue

twaik commented 10 months ago

@sylirre what about rebuilding imagemagic?

sylirre commented 10 months ago

I'm saying exactly about imagemagick package.

Screenshot_20231223-121249

sylirre commented 10 months ago

Issue with chafa unreproducible.

Suletta-Majo commented 10 months ago

Chafa's problems may be unique to I messed around with a lot of things. 😓 If other people don't seem to have a problem, you can ignore them

truboxl commented 10 months ago

If you can reproduce the chafa issue again, please log new issue. We will see how to fix this imagemagick issue here.

helpimnotdrowning commented 10 months ago

Chafa's problems may be unique to I messed around with a lot of things. 😓 If other people don't seem to have a problem, you can ignore them

I had some similar issues where a bunch of different programs were complaining about missing libraries a little while ago, it was fixed with pkg upgrade, since I had never done it since I installed termux, maybe that could help?

Suletta-Majo commented 10 months ago
Thanks! Unrelated to the topic my trouble is fixed Thanks I got some errors on _pkg upgrade_, so I selected all in _termux-change-repo_. As a countermeasure against errors,i'm tryed _apt-get update --fix-missing_ etc. is done as it is said. Chafa on the terminal now shows images as before! Calling from python is the failed, but If you search the net, you will find that the match is bad with the latest 7.x version of imagemagick, which may be a different problem This is the first time I've called it as a program, so it's possible that I'm just writing it wrong _I want to post it folded because it has nothing to do with the agenda, but I don't know how to do it, so I'll leave it as it is, thank you :)_
superjamie commented 10 months ago

Same here:

$ wget https://cdn.mobygames.com/182b4910-aba5-11ed-8bb9-02420a000197.webp
$ magick identify 182b4910-aba5-11ed-8bb9-02420a000197.webp
identify: unable to read image data `182b4910-aba5-11ed-8bb9-02420a000197.webp' @ error/constitute.c/ReadImage/991.

If I use ImageMagick in a proot (eg: Alpine) then it works fine, so that's at least a workaround.

ez-me commented 10 months ago

I tried compiling ImageMagick from within termux, and it seems to work perfectly.

I did have an issue with MagicCore/random.c:381 having an implied function, but you can ~remove~ patch that MAGICKCORE_HAVE_GETENTROPY out without too much harm being done (I think).

landfillbaby commented 10 months ago

seems to be fixed in 7.1.1.25?

superjamie commented 10 months ago

Confirmed, working for me in 7.1.1.25

Suletta-Majo commented 10 months ago

in 7.1.1.25 In my environment, it seems that there are things that can be identified and things that cannot be identified

$ magick identify Stest.png
Stest.png PNG 640x360 640x360+0+0 8-bit sRGB 271405B 0.000u 0:00.000
$ magick identify myfig.png
identify: unable to read image data `myfig.png' @ error/constitute.c/ReadImage/991.

What I couldn't identify is a simple test program in my post below
Here's an image of a graph by matplotlib made by python (there is an image in the final post[^1])
https://github.com/termux/termux-packages/issues/18640#issuecomment-1863460919 [^1]: I just confirmed that the image I uploaded to github has changed md5sum
There may be difficulties in using it for verification original md5sum myfig.png 401bc1b1c5b2f6921e17e60368d8e910

It's somewhat similar to the post that illustrates this issue. https://github.com/termux/termux-packages/issues/18740#issuecomment-1866999224 i wonder Maybe the binary header is foreign as a difference normallyPNG?

AgentConDier commented 10 months ago

Yup, 7.1.1-25 seems good. All my previously broken test cases are working again.

truboxl commented 10 months ago

@Suletta-Majo you can zip the image and upload here

Suletta-Majo commented 10 months ago

Thank you I zipped it myfig.zip Perhaps because of the recreate file, the MD5 has changed from the previous one, but the error was the same
usually I don't use ImageMagick directly like this, so I don't have a serious problem. When I tried it, it was an error, so I posted it

TGSMLM commented 10 months ago

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。

landfillbaby commented 10 months ago

ok so using unzip myfig.zip && identify -verbose myfig.png in my termux home dir works fine. it might be a permissions thing. what's the output of ls -l myfig.png on the version before zipping?

Suletta-Majo commented 10 months ago

ls -l myfig.png

[288ms][1][~/pyprog]$ ls -l myfig.png
-rw------- 1 u0_a365 20128 Jan  1 23:50 myfig.png
[55ms][~/pyprog]$ ls -l Stest.png
-rw------- 1 u0_a365 271405 Aug 28 07:10 Stest.png

[33ms][~/pyprog]$ magick identify myfig.png
identify: unable to read image data `myfig.png' @ error/constitute.c/ReadImage/991.

If it is possible to identify someone other than myself, it meanings I think it is just that my environment is broken :/
Thank you very much for verifying it I didn't back up my system properly, so I'm going to rebuild my environment from reinstalling termux It's not that difficult because just python and modules :)

P.S after rebuilding a relatively clean termux environment
I was able to display myfig.png information

~ $ magick identify myfig.png
myfig.png PNG 640x480 640x480+0+0 8-bit sRGB 20128B 0.000u 0:00.000
truboxl commented 10 months ago

Ok then I will go ahead and close the issue since everyone agree magick is working now