ImagickDemos icon indicating copy to clipboard operation
ImagickDemos copied to clipboard

Querying for Delegates

Open cancan101 opened this issue 1 year ago • 2 comments

Looking for an example of how to query for installed delegates? This would be similar to (using the binary): convert -list configure | grep DELEGATES

Currently libraries like Pimcore shell out to binary rather than using the php library: https://github.com/pimcore/pimcore/blob/fcedfd356ba726ba238996aa4777b2178366367d/lib/Tool/Requirements.php#L622-L637

cancan101 avatar Dec 10 '24 19:12 cancan101

You should be able to call Imagick::getConfigureOptions and that has an entry for 'DELEGATES'.

I presume that is the actual usable delegates rather than just the compile 'suggestions' of which ones to try to compile. But it might be worth checking.

shell out to binary rather than using the php library

Probably nowt wrong that tbh...

Danack avatar Dec 10 '24 20:12 Danack

I presume that is the actual usable delegates rather than just the compile 'suggestions' of which ones to try to compile. But it might be worth checking.

It's definitely only the compiled-in delegates, last time I screwed up a build and some of the delegates got missed, I confirmed that by checking they were missing from the list.

The same list is also shown in the magick --version output of IM7 (wrapped for readability):

$ magick --version
Version: ImageMagick 7.1.1-46 Q16-HDRI x86_64 22747
 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype
 gslib gvc heic jbig jng jp2 jpeg jxl lcms lqr ltdl lzma
 openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml
 zip zlib zstd
Compiler: gcc (14.2)

Unfortunately magick -list Delegate is even less useful than the -list configure output, as it only lists the external-command based delegates (not library-based delegates like jxl, freetype, pangocairo, etc...) and in a byzantine format not suitable for machine consumption (not wrapped because it would only make it harder to read):

$ magick -list Delegate
Delegate                Command
-------------------------------------------------------------------------------
    blender =>          "blender' -b '%i' -F PNG -o '%o''\n'magick' -concatenate '%o*.png' '%o"
        bpg =>          "bpgdec' -b 16 -o '%o.png' '%i'; /usr/bin/mv '%o.png' '%o"
  clipboard =>          "xclip' -selection clipboard -o > '%o"
 dng:decode =>          "/usr/bin/mkdir '%u-config';/usr/bin/mv '%i' '%i.%e'; 'darktable-cli' --import '%i.%e' '%u.tif' --core --configdir '%u-config' > '%u';/usr/bin/rm -r '%u-config"
        doc =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
       docx =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        dot =>          "dot' -Tsvg '%i' -o '%o"
        dvi =>          "dvips' -sstdout=%%stderr -o '%o' '%i"
        emf =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        eps<=>pdf        "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 '-sDEVICE=pdfwrite' '-sOutputFile=%o' '-f%i"
        eps<=>ps         "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=ps2write' '-sOutputFile=%o' '-f%i"
       epub =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        hpg =>          "hp2xx' -sstdout=%%stderr -m eps -f `basename '%o'` '%i';     /usr/bin/mv -f `basename '%o'` '%o"
       hpgl =>          "hp2xx' -sstdout=%%stderr -m eps -f `basename '%o'` '%i';     /usr/bin/mv -f `basename '%o'` '%o"
        htm =>          "html2ps' -U -o '%o' '%i"
       html =>          "html2ps' -U -o '%o' '%i"
http:decode =>          "curl' -s -L -o '%u.dat' 'http:%M"
https:decode =>          "curl' -s -L -o '%u.dat' 'https:%M"
       ilbm =>          "ilbmtoppm' '%i' > '%o"
        jpg<= lep        "lepton' '%i' '%o"
        jxr =>          "/usr/bin/mv '%i' '%i.jxr'; 'JxrDecApp' -i '%i.jxr' -o '%o.tiff'; /usr/bin/mv '%i.jxr' '%i'; /usr/bin/mv '%o.tiff' '%o"
        lep =>          "lepton' '%i' '%o"
       miff<= show       "magick' display -immutable -delay 0 -title '%M' '%i"
        odg =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        odt =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        pdf<=>eps        "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=eps2write' '-sPDFPassword=%a' '-sOutputFile=%o' '-f%i"
        pdf<=>ps         "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=ps2write' '-sPDFPassword=%a' '-sOutputFile=%o' '-f%i"
        png<= bpg        "bpgenc' -b 12 -q '%~' -o '%o' '%i"
        png<= clipboard  "xclip' -selection clipboard -t image/png '%i"
        png<= webp       "cwebp' -quiet -q %Q '%i' -o '%o"
        pnm<= trace      "potrace' --svg --output '%o' '%i"
        pnm<= ilbm       "ppmtoilbm' -24if '%i' > '%o"
        ppt =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
       pptx =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
         ps<= prt        "lpr' '%i"
         ps<=>eps        "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=eps2write' '-sOutputFile=%o' '-f%i"
         ps<=>pdf        "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pdfwrite' '-sOutputFile=%o' '-f%i"
         ps<= print      "@LPRDelegateDefault@ '%i"
      shtml =>          "html2ps' -U -o '%o' '%i"
        sid =>          "mrsidgeodecode' -if sid -i '%i' -of tif -o '%o' > '%u"
        svg =>          "rsvg-convert' --dpi-x %x --dpi-y %y -o '%o' '%i"
       tiff<= jxr        "/usr/bin/mv '%i' '%i.tiff'; 'JxrEncApp' -i '%i.tiff' -o '%o.jxr'; /usr/bin/mv '%i.tiff' '%i'; /usr/bin/mv '%o.jxr' '%o"
       tiff<= wdp        "/usr/bin/mv '%i' '%i.tiff'; 'JxrEncApp' -i '%i.tiff' -o '%o.jxr'; /usr/bin/mv '%i.tiff' '%i'; /usr/bin/mv '%o.jxr' '%o"
       tiff<= text       "tesseract' '%i' '%u'; /usr/bin/mv '%u.txt' '%o"
       tiff<= launch     "gimp' '%i"
video:decode =>          "ffmpeg' -nostdin -loglevel error -i '%s' -an -f rawvideo -y %s '%s"
        vsd =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
       vsdx =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        wdp =>          "/usr/bin/mv '%i' '%i.jxr'; 'JxrDecApp' -i '%i.jxr' -o '%o.tiff'; /usr/bin/mv '%i.jxr' '%i'; /usr/bin/mv '%o.tiff' '%o"
       webp =>          "dwebp' -pam '%i' -o '%o"
        wmf =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
        xls =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"
       xlsx =>          "libreoffice' --convert-to pdf --outdir `dirname '%i'` '%i' 2> '%u'; /usr/bin/mv '%i.pdf' '%o"

That list does indirectly point out one thing to keep in mind, though: For the external-command delegates, some of those may not really be available if you don't have the appropriate binaries installed. (Things like libreoffice, dwebp, ffmpeg, gimp, blender, tesseract, whatever JxrEncApp or mrsidgeodecode are, etc...)

ferdnyc avatar Mar 31 '25 18:03 ferdnyc