Friday, 31 December 2021

ImageMagick installation with Alfresco and ATS

 

I installed ImageMagick 7.0.11 with configured it with ACS7.0 as well as ACS7.1 on RHEL 8.

 

Steps:

  • For ImageMagick, follow this link - https://download.imagemagick.org/ImageMagick/script/download.php
  • Downloaded following rpm files from above link:
    • ImageMagick-7.0.11-13.x86_64.rpm
    • ImageMagick-libs-7.0.11-13.x86_64.rpm
  • And then executed below commands for installation:
    • dnf install ImageMagick-libs-7.0.11-13.x86_64.rpm
    • dnf install ImageMagick-7.0.11-13.x86_64.rpm
    • dnf upgrade
    • dnf search ImageMagick
    • dnf show ImageMagick

 

  • ImageMagick would be installed under /bin . That is under /usr/bin.
  • To verify, you can execute these commands :  magick –version   OR  convert –version

 

 

 

Output should be as follows:

Version: ImageMagick 7.0.11-13 Q16 x86_64 2021-05-17 https://imagemagick.org

Copyright: (C) 1999-2021 ImageMagick Studio LLC

License: https://imagemagick.org/script/license.php

Features: Cipher DPC HDRI Modules OpenMP(4.5)

Delegates (built-in): bzlib cairo djvu fontconfig freetype gslib jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zlib


Adding a stackoverflow link here of the related post :

https://stackoverflow.com/questions/56057895/alfresco-thumbnail-creation-not-works/64596512#64596512

-----------------------------------------------------------------------------------------------------

Other ImageMagick useful links & techniques:

Alfresco ImageMagick Problems link:

https://stackoverflow.com/questions/56057895/alfresco-thumbnail-creation-not-works

https://superuser.com/questions/1467574/how-to-configure-imagemagick-to-work-with-alfresco-on-centos7

https://askubuntu.com/questions/745660/imagemagick-png-delegate-install-problems/1346178#1346178


Commands:

  • convert filename destinationfilename
  • convert -thumbnail x500 sample-pdf-file.pdf -quality 50 jpg:samplepdf.jpg
  • wkhtmltopdf --disable-javascript --quiet --encoding UTF-8 --load-error-handling ignore /home/alfadmin/test.html  /home/alfadmin/test.pdf
  • wkhtmltopdf --disable-javascript --quiet --encoding UTF-8 --load-error-handling ignore /opt/test.html /opt/test.pdf
  • ./configure --enable-shared
  • ./configure --prefix=/usr/local
  • ./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp
  • yum install libjpeg libjpeg-devel
  • ./configure --enable-shared=yes --x-libraries=/usr/lib64
  • ./configure --prefix=/usr/lib64
  • ./configure --prefix=/usr/lib
  • export CPPFLAGS=-I/usr/local/include
  • export LDFLAGS=-L/usr/local/lib
  • ./configure --prefix=/usr/local
  • export X_LIBS=/usr/lib64
  • ./configure --prefix=/usr/local
  • make
  • make install
  • find / -name libjpeg*
  • find / -name libpdf*
  • magick identify -format %wx%h testimage.gif
  • magick identify -format %wx%h testimage.png
  • find / -name policy.xml  // try adding the following lines:
    • <policy domain="coder" rights="read|write" pattern="PDF" />
    • <policy domain="coder" rights="read|write" pattern="LABEL" />
  • magick -version
  • To remove ImageMagick:
    • cd /usr/local/bin
    • yum remove magick
    •  make uninstall
    • cd /opt/softwares/ImageMagick-7.0.11-13
    • make uninstall
    • yum remove ImageMagick
    • which magick

  • Other commands to remove and check:
    • yum remove convert
    • yum remove identify
    • which imagemagick
    • which magick
  • Alfresco-global.properties ImageMagick and ATS properties:
    • # JodConverter
    • # ------------
    • # Transformations supported by OpenOffice/LibreOffice
    • content.transformer.JodConverter.extensions.doc.pdf.maxSourceSizeKBytes=10240
    • content.transformer.JodConverter.extensions.docx.pdf.maxSourceSizeKBytes=5120
    • # ActiveMQ properties:I
    • # NOTE that if activemq running on ACS instance only, then in place of 172.16.12.12 IP address, keep localhost
    • messaging.broker.url=failover:(tcp://IP_ADDR:61616)?timeout=3000&jms.useCompression=true
    • messaging.subsystem.autoStart=false
    • #Enabling and disabling Local or Transform Service transforms 
    • transform.service.enabled=true
    • local.transform.service.enabled=true
    • legacy.transform.service.enabled=false
    • # Shared File Store properties:
    • sfs.url=http://localhost:8099
    • sfs.endpoint=${sfs.url}/alfresco/api/-default-/private/sfs/versions/1/file
    • # Transform Router property:
    • transform.service.url=http://IP_ADDR:8095/
    • # Transform Core properties:
    • localTransform.core-aio.url=http://IP_ADDR:8090/
    • alfresco-pdf-renderer.url=http://IP_ADDR:8090/
    • jodconverter.url=http://IP_ADDR:8090/
    • img.url=http://IP_ADDR:8090/
    • tika.url=http://IP_ADDR:8090/
    • transform.misc.url=http://IP_ADDR:8090/

  • Alfresco Transform Services:
    • Start 3 jars. You can create a custom ats.sh file as follows which can start 3 jars in parallel:
    • Contents of ats.sh:
            #!/bin/bash
            # Execute ATS Jars

            START="start"
            STOP="stop"
            RESTART="restart"
            FORCESTOP="force-stop"

            echo command exectued for "$1"

            if [[ "$1" == "$FORCESTOP" ]]; then
                kill $(ps aux | grep "alfresco-shared-file-store-controller-0.13.0.jar" | grep -v grep | awk '{print $2}')
                kill $(ps aux | grep "alfresco-transform-core-aio-boot-2.3.10.jar" | grep -v grep | awk '{print $2}')
                kill $(ps aux | grep "alfresco-transform-router-1.3.2.jar" | grep -v grep | awk '{print $2}')
                kill $(ps aux | grep "program/soffice.bin" | grep -v grep | awk '{print $2}')
else
            if [[ "$1" == "$STOP" || "$1" == "$RESTART" ]]; then
        controller_pid=$(ps -ef | grep "alfresco-shared-file-store-controller-0.13.0.jar" | grep -v grep | awk '{print $2}')
            if $(ps -p $controller_pid >/dev/null 2>&1); then
                kill -9 $controller_pid
                echo "alfresco-shared-file-store-controller-0.13.0.jar process stopped"
            else
                echo "alfresco-shared-file-store-controller-0.13.0.jar process already not running"
            fi
        fi
    if [[ "$1" == "$START" || "$1" == "$RESTART" ]]; then
        echo "alfresco-shared-file-store-controller starting!!!!!!"
        nohup /software/java/jdk-11.0.2/bin/java -jar /software/alfresco-transform-service/alfresco-shared-file-store-controller-0.13.0.jar &>nohup1.out &
        # echo $! >pid_alfresco-shared-file-store-controller.txt
    fi

    if [[ "$1" == "$STOP" || "$1" == "$RESTART" ]]; then
        core_pid=$(ps -ef | grep "alfresco-transform-core-aio-boot-2.3.10.jar" | grep -v grep | awk '{print $2}')
        if $(ps -p $core_pid >/dev/null 2>&1); then
            kill -9 $core_pid
            echo "alfresco-transform-core-aio-boot-2.3.10.jar process stopped"
        else
            echo "alfresco-transform-core-aio-boot-2.3.10.jar process already not running"
        fi
    fi
    if [[ "$1" == "$START" || "$1" == "$RESTART" ]]; then
        echo "alfresco-transform-core-aio-boot-2.3.10.jar starting!!!!!!"
        nohup /software/java/jdk-11.0.2/bin/java -DPDFRENDERER_EXE="/software/alfresco-pdf-renderer/alfresco-pdf-renderer" -DLIBREOFFICE_HOME="/opt/libreoffice6.3" -DIMAGEMAGICK_ROOT="/usr/bin" -DIMAGEMAGICK_DYN="/usr/lib" -DIMAGEMAGICK_EXE="/usr/bin/convert" -DACTIVEMQ_URL="failover:(tcp://localhost:61616)?timeout=3000" -DFILE_STORE_URL=http://172.90.1.212:8099/alfresco/api/-default-/private/sfs/versions/1/file -jar /software/alfresco-transform-service/alfresco-transform-core-aio-boot-2.3.10.jar &>nohup2.out &
        # echo $! >pid_alfresco-transform-core-aio-boot.txt
    fi

    if [[ "$1" == "$STOP" || "$1" == "$RESTART" ]]; then
        router_pid=$(ps -ef | grep "alfresco-transform-router-1.3.2.jar" | grep -v grep | awk '{print $2}')
        if $(ps -p $router_pid >/dev/null 2>&1); then
            kill -9 $router_pid
            echo "alfresco-transform-router-1.3.2.jar process stopped"
        else
            echo "alfresco-transform-router-1.3.2.jar process already not running"
        fi
    fi
    if [[ "$1" == "$START" || "$1" == "$RESTART" ]]; then
        echo "alfresco-transform-router-1.3.2.jar starting!!!!!!"
        nohup /software/java/jdk-11.0.2/bin/java -DCORE_AIO_URL=http://localhost:8090 -DCORE_AIO_QUEUE=org.alfresco.transform.engine.aio.acs -DACTIVEMQ_URL="failover:(tcp://localhost:61616)?timeout=3000" -DFILE_STORE_URL=http://172.90.1.212:8099/alfresco/api/-default-/private/sfs/versions/1/file -jar /software/alfresco-transform-service/alfresco-transform-router-1.3.2.jar &>nohup3.out &
        # echo $! >pid_alfresco-transform-router.txt
    fi
    if [[ "$1" == "$STOP" || "$1" == "$RESTART" ]]; then
        soffice_pid=$(ps -ef | grep "program/soffice.bin" | grep -v grep | awk '{print $2}')
        if $(ps -p $soffice_pid >/dev/null 2>&1); then
            kill -9 $soffice_pid
        else
            echo "No soffice process running"
        fi
    fi
fi