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

Imagemagick graphics corruption for png #2214

Closed
MolotovCherry opened this issue Feb 28, 2018 · 3 comments
Closed

Imagemagick graphics corruption for png #2214

MolotovCherry opened this issue Feb 28, 2018 · 3 comments
Labels
bug report Something is not working properly. help wanted Help is wanted in order to solve the issue.

Comments

@MolotovCherry
Copy link

MolotovCherry commented Feb 28, 2018

Imagemagick Version 7.0.7-22 aarch64

image.png

Commands

$ magick image.png -transparent white tmp.png
$ magick tmp.png -alpha extract tmp2.png
$ magick tmp2.png \
> -define connected-components:mean-color=true \
> -define connected-components:area-threshold=30 \
> -connected-components 4 \
> tmp3.png
$ magick tmp3.png -morphology Dilate Octagon output.png

output.png

Corruptions like this are very common. No matter what commands I use with imagemagick, the corruptions happen. Sometimes it's fine, but usually the corruptions happen.

This problem probably happens with any kind of image, not only png. Sometimes the program will segfault, other times it says it ran out of memory. It is very sporadic.

This was referenced Feb 28, 2018
@fornwall fornwall added bug report Something is not working properly. help wanted Help is wanted in order to solve the issue. labels Feb 28, 2018
@MolotovCherry
Copy link
Author

MolotovCherry commented Mar 5, 2018

Here is my workaround for the bad imagemagick behavior in Termux:

Using a separate build of imagemagick works perfectly (it's not related to termux). You can get it here, Clang/GCC OpenMP build. Get it to work by, unset LD_PRELOAD, and add the lib path to LD_LIBRARY_PATH

P.s. you also need to place some special files in $HOME/.config/ImageMagick. Find them under $PREFIX/etc/ImageMagick-7 (you'll need to install pkg install imagemagick the original package to get the files)

My setup:

unset LD_PRELOAD
PATH=$PATH:$HOME/magick/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/magick/lib

(Getting annoying unused DT entry warnings? Ignore them, the program will still work, but if you can't ignore, then you can clean them)

$ pkg install termux-elf-cleaner
$ termux-elf-cleaner magick
termux-elf-cleaner: Removing version section from 'magick'
termux-elf-cleaner: Removing version section from 'magick'
termux-elf-cleaner: Removing the DT_VERNEEDED dynamic section entry from 'magick'
termux-elf-cleaner: Removing the DT_VERNEEDNUM dynamic section entry from 'magick'
termux-elf-cleaner: Removing the DT_VERSYM dynamic section entry from 'magick'
$ termux-elf-cleaner libMagickCore-7.so
termux-elf-cleaner: Removing version section from 'libMagickCore-7.so'
termux-elf-cleaner: Removing version section from 'libMagickCore-7.so'
termux-elf-cleaner: Removing the DT_RPATH dynamic section entry from 'libMagickCore-7.so'
termux-elf-cleaner: Removing the DT_VERNEEDED dynamic section entry from 'libMagickCore-7.so'
termux-elf-cleaner: Removing the DT_VERSYM dynamic section entry from 'libMagickCore-7.so'
termux-elf-cleaner: Removing the DT_VERNEEDNUM dynamic section entry from 'libMagickCore-7.so'
$ termux-elf-cleaner libMagickWand-7.so
termux-elf-cleaner: Removing version section from 'libMagickWand-7.so'
termux-elf-cleaner: Removing version section from 'libMagickWand-7.so'
termux-elf-cleaner: Removing the DT_VERNEEDED dynamic section entry from 'libMagickWand-7.so'
termux-elf-cleaner: Removing the DT_VERNEEDNUM dynamic section entry from 'libMagickWand-7.so'
termux-elf-cleaner: Removing the DT_VERSYM dynamic section entry from 'libMagickWand-7.so'

The build for termuxarch also works. If anybody wants to use this binary, you can use termux Arch and install it there.

pkg install wget
wget https://sdrausty.github.io/TermuxArch/setupTermuxArch.sh
bash setupTermuxArch.sh
pacman -S imagemagick

@fornwall
Copy link
Member

Could you check if the latest version of the imagemagick package (version 7.0.7.38) fixes this problem?

If not, does running export OMP_NUM_THREADS=1 before invoking magick help?

@fornwall
Copy link
Member

I'm closing this issue in favour of #1314.

@termux termux locked and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug report Something is not working properly. help wanted Help is wanted in order to solve the issue.
Projects
None yet
Development

No branches or pull requests

2 participants