tfuxu / Halftone

Give your images that pixel art-like style
GNU General Public License v3.0
103 stars 16 forks source link

Facing no delegate module error while snapping this app #24

Closed soumyaDghosh closed 6 months ago

soumyaDghosh commented 1 year ago

Hii, I have been trying to snap this app. The GUI shows up, but, whenever I add any kind of image file, I face this error.

Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/snap/halftone/current/usr/share/halftone/halftone/utils/killable_thread.py", line 27, in _run
    self._run_backup()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/snap/halftone/current/usr/share/halftone/halftone/views/dither_page.py", line 139, in update_preview_image
    self.preview_image_path = HalftoneImageMagick().dither_image(path, self.output_options)
  File "/snap/halftone/current/usr/share/halftone/halftone/backend/magick.py", line 21, in dither_image
    with Image(filename=path) as img:
  File "/snap/halftone/x15/usr/lib/python3.10/dist-packages/wand/image.py", line 9365, in __init__
    self.read(filename=filename)
  File "/snap/halftone/x15/usr/lib/python3.10/dist-packages/wand/image.py", line 10120, in read
    self.raise_exception()
  File "/snap/halftone/x15/usr/lib/python3.10/dist-packages/wand/resource.py", line 225, in raise_exception
    raise e
wand.exceptions.MissingDelegateError: NoDecodeDelegateForThisImageFormat `PNG' @ error/constitute.c/ReadImage/781

In the snap, magick is installed same way as it's done in flatpak. At first I facing the same issue but with 'JPG' instead of 'PNG' Later, I added

      - --with-modules=yes
      - --enable-delegate-build=yes
      - --with-png=yes

But, now I am getting this error. But, the snap itself still have all the same files and libraries as the flatpak. Am I missing anything, or any ENVIRONMENT VARIABLE is missing to point towards the magick libraries.

This is the snapcraft.yaml for your help:

name: halftone # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
adopt-info: halftone
version: '0.2.0'
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

parts:     
  magick:
    plugin: autotools
    source: https://github.com/ImageMagick/ImageMagick.git
    source-commit: "920f79206ff59f30a4cff22c9c9c393508b82663"
    autotools-configure-parameters:
      - --prefix=/usr
      - --with-heic=yes
      - --with-rsvg=yes 
      - --with-modules=yes
      - --enable-delegate-build=yes
      - --with-png=yes
    prime:
      - -usr/lib/pkgconfig
      - -usr/include
      - -usr/share
  halftone:
    after: [ magick ]
    # See 'snapcraft plugins'
    plugin: meson
    source: https://github.com/tfuxu/Halftone.git
    source-tag: '0.3.0'
    meson-parameters:
      - --prefix=/snap/halftone/current/usr
      - -Dbuildtype=release
    override-pull: |
      craftctl default
      patch -p1 < $CRAFT_PROJECT_DIR/halftone.patch
      pip install --prefix=$CRAFT_PART_INSTALL/usr Wand
    build-packages:
      - blueprint-compiler
      - execstack
    stage-packages:
      - libjpeg62
    override-build: |
      craftctl default
      mkdir -p $CRAFT_PART_INSTALL/meta/gui
      cp -r $CRAFT_PART_INSTALL/snap/halftone/current/usr/share/icons $CRAFT_PART_INSTALL/meta/gui/
      for i in `find $CRAFT_PART_INSTALL/meta/gui/icons -name "*.svg" -o -name "*.png"`; do
        mv $i "`dirname $i`/snap.$CRAFT_PROJECT_NAME.`basename $i`"
      done
    override-prime: |
      craftctl default
      if [ "$CRAFT_ARCH_TRIPLET" = "arm-linux-gnueabihf" ]; then
      execstack --clear-execstack usr/lib/arm-linux-gnueabihf/libde265.so.0.1.1
      fi
    parse-info: [usr/share/appdata/io.github.tfuxu.Halftone.appdata.xml]
    organize:
      snap/halftone/current: .
      usr/local: usr
      usr/lib/python3: usr/lib/python3.10
    prime:
      - -snap/halftone
slots:
  halftone:
    interface: dbus
    bus: session
    name: io.github.tfuxu.Halftone
apps:
  halftone:
    command: usr/bin/halftone
    common-id: io.github.tfuxu.Halftone
    extensions: [gnome]
    environment:
      PYTHONPATH: $SNAP/usr/lib/python3.10/dist-packages:$PYTHONPATH
      MAGICK_HOME: $SNAP/usr
      MAGICK_CODER_MODULE_PATH: $SNAP/usr/lib/
    plugs:
      - home
tfuxu commented 1 year ago

You might want to wait a little bit longer with making a snap package, as I'm going to replace ImageMagick with Pillow in the next release, so all of this workarounds won't be probably needed in 0.4.0.

BTW, if you still want to make this work, I found this topic on Snapcraft's forum: https://forum.snapcraft.io/t/the-imagemagick-remote-part/9003

soumyaDghosh commented 1 year ago

Thank you.. I must wait then. Cause making complicated things just for one release is not a good choice I guess.

tfuxu commented 1 year ago

@soumyaDghosh If you want, you can work on snap package for the current release, as it seems that issue https://github.com/tfuxu/Halftone/issues/28 will be harder do implement than I initially thought. There's just a lot of bugs and deprecated code in hitherdither which I need to fix before bundling it in Halftone.

soumyaDghosh commented 6 months ago

Hi @tfuxu I am very sorry, I took so much time. Actually got frustrated with the magick's delegate not found error. But, finally, almost a year later, I sat with it again and guess what? I have made it!!!!!

Even though the version is 0.6.0 for now(no gnome 46 yet in snaps, still in testing phase), it works! and works perfectly.

tfuxu commented 6 months ago

Glad to hear that!

soumyaDghosh commented 6 months ago

Glad to hear that!

Would you like to add a badge about the package in your repo? Or want to make it an official one?

tfuxu commented 6 months ago

Would you like to add a badge about the package in your repo?

Added in #73

soumyaDghosh commented 6 months ago

Thank you!