Announcement

Collapse
No announcement yet.

PDF - Thumbs with ImageMagick and Ghostscript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PDF - Thumbs with ImageMagick and Ghostscript

    ImageMagick6 ist installed and working
    Ghostscript is installed and working

    Code:
    convert \test.pdf \test.jpg 2>&1
    shellscript is working..

    PHP Code:
    $im = new Imagick();
    $im->readimage('/test.pdf[0]');
    $im->setImageFormat('jpeg');    
    $im->writeImage('/thumb.jpg');
    $im->clear();
    $im->destroy(); 
    PHP is working...


    I think, there is no need for delegate.xml because shell and PHP are working. Anyway, inserted:

    Code:
     <delegate decode="pdf" encode"jpg"  command="&quot;convert %i %o&quot;"/>

    Anyway, getting error in admincp:
    Failed to automatically validate that Ghostscript is installed & configured with ImageMagick for PDF to JPG conversion.
    Please ensure that Ghostscript is installed and that relevant entries in ImageMagick's delegates.xml point to the proper path for Ghostscript's executable. You can ignore this and set this option to "Yes" if PDF conversion already works without the delegates check.

    Ignoring this has no effect.

    Uploading images - thumbs are createt.
    uploading pdf - thumb not and also no error...

    Is this feature working? What is wrong?

    P.S. tryed with VB 5.3.3 RC2
    Last edited by AScherff; Fri 15 Sep '17, 2:43am. Reason: P.S.

  • #2
    Your delegate command should actually call Ghostscript. If it isn't on the PATH checked by the server, you would need the path in the command. However, if it works in the shell script, it may be configured during compile so try without the explicit delegate.

    Code:
    <delegate decode="pdf" encode"jpg"  command="gs &quot;convert %i %o&quot;"/>
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      stil not working for me - but

      in /atachments i can see hat a .thumb file is created and it is a jpg-file but in a very,very poor quality - even when the delegate is not set.

      I can dig into, if you give me a hint where the thumb is created. I think somewhere in in /core/vb/image/imagemagick.php ?

      Comment


      • #4
        Offhand, I don't know where it is set in the code.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API - Full / Mobile
        Vote for your favorite feature requests and the bugs you want to see fixed.

        Comment


        • #5
          Hmmm, an old one but I have just come across this.

          I can open a shell command and I can find the Imagmagick and GS working fine. I opened a support ticket to see if I can have the host look into this as it seems to be working from shell, just not within vb5.6.1

          Is there anything I can change within vB to work around this, I am sure the answer is no but I ask anyway.



          Thanks In Advance

          John

          Comment


          • #6
            Is Ghostscript available in the path or do you need to traverse to its location to us it?
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API - Full / Mobile
            Vote for your favorite feature requests and the bugs you want to see fixed.

            Comment


            • #7
              Wayne

              The error to me is stating it cannot find GS or unable to use it. So i queried my host on this and the reply is below.

              I have checked the server settings in detail and unfortunately I could not find the reason for this error. Imagick and Ghostscript are working fine and I could not see any errors in the logs. The following delegates are currently included in the ImageMagick installation

              [[email protected]:/root]$ convert -list configure | grep DELEGATES
              DELEGATES bzlib mpeg freetype gslib jng jpeg lcms lzma openexr pango png tiff wmf x xml zlib
              DELEGATES bzlib freetype gslib jng jpeg lcms ltdl lzma openexr png ps tiff wmf x xml zlib

              Could you please check this with the vbulletin support regarding this issue? Without a specific error message or the exact command that the script is using, we are unable to resolve the problem from our end. So please check with them and let us know if the script requires any changes in the server setting to make it work correctly.


              I have checked the server settings in detail and unfortunately I could not find the reason for this error. Imagick and Ghostscript are working fine and I could not see any errors in the logs. The following delegates are currently included in the ImageMagick installation

              [[email protected]:/root]$ convert -list configure | grep DELEGATES
              DELEGATES bzlib mpeg freetype gslib jng jpeg lcms lzma openexr pango png tiff wmf x xml zlib
              DELEGATES bzlib freetype gslib jng jpeg lcms ltdl lzma openexr png ps tiff wmf x xml zlib

              Could you please check this with the vbulletin support regarding this issue? Without a specific error message or the exact command that the script is using, we are unable to resolve the problem from our end. So please check with them and let us know if the script requires any changes in the server setting to make it work correctly.


              So I am back to you guys Wayne, can you enquire as to the exact command being executed for the PDF to JPG conversion so I can pass it on.

              There is no errors when I enable Imagmagick and its 6.9x (I seen the other thread on 7)

              Only error is when i set PDF to JPG to Yes and i see this.

              Error Failed to automatically validate that Ghostscript is installed & configured with ImageMagick for PDF to JPG conversion. Please ensure that Ghostscript is installed and that relevant entries in ImageMagick's delegates.xml point to the proper path for Ghostscript's executable. You can ignore this and set this option to "Yes" if PDF conversion already works without the delegates check.

              John
              Thanks In Advance

              John

              Comment


              • #8
                Hello Wayne

                I am still holding an open ticket with the host on this.

                As above the host has went through a few test scenarios and cannot find any issue so they are at the point they would like some information so they can investigate more.

                So I am back to you guys Wayne, can you enquire as to the exact command being executed for the PDF to JPG conversion so I can pass it on.
                If you can help please I would greatly appreciate it

                John



                Thanks In Advance

                John

                Comment


                • #9
                  It calls either identify or convert depending on the action. The error you're getting is because Imagemagick is not returning Ghostscript as a delegate to deal with PDF files.

                  Assuming you're on Linux...

                  Code:
                                  $result = $this->fetchImExec(
                                      'convert',
                                      '-list delegate  |grep -i "pdf" ',
                                      array(),
                                      true
                                  );
                  Then provided your ImageMagick delegate XML file points to the gscript executable properly, it will say "true" or "false". If false, it returns an error.

                  Code:
                                  if (
                                      strpos($outputText, 'postscript delegate failed') !== false OR
                                      strpos($outputText, 'pdfdelegatefailed') !== false  // IM 6.9.8
                                  )
                                  {
                                      throw new vB_Exception_Api('install_ghostscript_to_resize_pdf');
                                  }

                  Full code is in /core/vb/image/imagemagick.php canThumbnailPdf() line 302.

                  You must also use ImageMagick 6 at this time. ImageMagick 7 has not been tested or certified for use with vBulletin.
                  Last edited by Wayne Luke; Fri 5 Jun '20, 4:25pm.
                  Translations provided by Google.

                  Wayne Luke
                  The Rabid Badger - a vBulletin Cloud demonstration site.
                  vBulletin 5 API - Full / Mobile
                  Vote for your favorite feature requests and the bugs you want to see fixed.

                  Comment


                  • #10
                    Wayne, yes I seen the other thread on Version 7 and it is version 6 that is installed on the server.

                    Many thanks for the extra effort here Wayne Luke

                    John
                    Thanks In Advance

                    John

                    Comment


                    • #11
                      Wayne

                      I have a response. Everything seems to pint to something obscure.

                      We are seeing ghostscript(gs) as a delegate:
                      # convert -list delegate |grep -i pdf|grep gs\'
                      eps<=>pdf "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 '-sDEVICE=pdfwrite' '-sOutputFile=%o' '-f%i"
                      pdf<=>eps "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sPDFPassword='%a' '-sDEVICE=eps2write' '-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"
                      ps<=>pdf "gs' -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pdfwrite' '-sOutputFile=%o' '-f%i"

                      Please privide this inforamtion to vBulletin.

                      Thank you!
                      Regards.
                      Dave H.
                      Advanced Support Specialist

                      If there is anything else i can go poke / prod I would be grateful for any pointers.

                      John


                      Thanks In Advance

                      John

                      Comment


                      • #12
                        Having a similar problem:
                        Error in Image settings
                        Click image for larger version

Name:	ImageSettings.png
Views:	29
Size:	58.2 KB
ID:	4448776
                        However, diagnostics indicates everything is configured properly

                        Click image for larger version

Name:	Diagnostics.png
Views:	26
Size:	26.1 KB
ID:	4448777

                        Appearance in post:
                        Click image for larger version

Name:	Post.png
Views:	26
Size:	3.0 KB
ID:	4448778
                        Any ideas on how to fix this?
                        VB 5.6.4
                        PHP 7.4
                        MySQL 5.7.24

                        Comment


                        • #13
                          There was another recent topic on this and it appears to be an error that the thumbnail isn't shown in the post. Does the thumbnail appear on the activity stream within the user's profile?
                          Translations provided by Google.

                          Wayne Luke
                          The Rabid Badger - a vBulletin Cloud demonstration site.
                          vBulletin 5 API - Full / Mobile
                          Vote for your favorite feature requests and the bugs you want to see fixed.

                          Comment


                          • #14
                            Good question! Yes, the thumbnail shows in the condensed view of the Activity tab, but not when See More is clicked.
                            Click image for larger version

Name:	activityScrnMore.png
Views:	31
Size:	23.3 KB
ID:	4448792
                            Click image for larger version

Name:	activityScrnLess.png
Views:	25
Size:	13.0 KB
ID:	4448793
                            VB 5.6.4
                            PHP 7.4
                            MySQL 5.7.24

                            Comment

                          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                          Working...
                          X