How do I install GhostScript on IBMi?

The place for general PHP questions and hints for PHP on IBM i
joeupright
Posts: 11
Joined: Thu Feb 24, 2011 11:20 pm

How do I install GhostScript on IBMi?

Post by joeupright » Mon Aug 05, 2013 9:12 pm

Hello Everyone,

I am on an IBMi 720 system and very recently installed ZendServer 6.0.1 with PHP 5.4.11. I have created a PHP application and I would like to be able to show a preview of a PDF file for my end users. I am trying to convert PDF files to viewable thumbnails in either jpg or png format. All of the documentation that I read tells me that I must have Imagick and GhostScript installed. I do have Imagick installed and PDF is listed as one of the supported formats. It appears that I do not have GhostScript installed. I have been unable to find any recent documentation that pertains to installing GhostScript on the IBMi (formerly AS/400, System i, i Series). Any help would be greatly appreciated.

Thank you in advance.

Joe

erich_hieden
Posts: 393
Joined: Tue Jul 07, 2009 9:01 am

Re: How do I install GhostScript on IBMi?

Post by erich_hieden » Tue Aug 06, 2013 8:08 am

Hi Joe

Thanks to Michael Perzl’s fantastic site ( perzl.org), IBM i binaries of many OpenSource projects are available. Though, prior to installing ghostscript you need to prepare your system according to Open Source Binaries (you don’t need to install any packages using wwwinstall.sh – this script points to the old IBM binaries).

Once you’ve prepared your system according to the wiki’s instructions, run wwwinstallgs.sh (also copied to /QOpenSys/download) in a PASE shell (CALL QP2TERM) to install ghostscript and all its prereqs. Using --all as the sole argument will do the trick. To see the complete syntax, call this script without any arguments.

Unfortunately the forum won't let me attach .sh files to this post, so PM me your email address and i will send wwwinstallgs.sh to you directly.

So the complete installation looks like this:
  • call qp2term
  • cd /QOpenSys
  • mkdir download
  • chown qsys download
  • chmod 755 download
  • copy AIX installation files (rpm.rte, wget-1.9.1-1.aix5.1.ppc.rpm, setup.sh, wwwinstallgs.sh) to /QOpenSys/download using Windows Explorer, FTP or a similar tool
  • cd download
  • chown qsys *
  • setup.sh
  • wwwinstallgs.sh --all
  • exit
  • ADDENVVAR ENVVAR(GS_LIB) VALUE('/opt/freeware/bin:/opt/freeware/share/ghostscript/9.06/lib:/opt/freeware/share/ghostscript/9.06/fonts/fonts') LEVEL(*SYS)
  • in /www/zendsvr/conf/fastcgi.conf add
    SetEnv="GS_LIB=/opt/freeware/bin:/opt/freeware/share/ghostscript/9.06/lib:/opt/freeware/share/ghostscript/9.06/fonts/fonts"
    to enable ghostscript in PHP. If that doesn't help, call putenv('GS_LIB=/opt/freeware/bin:/opt/freeware/share/ghostscript/9.06/lib:/opt/freeware/share/ghostscript/9.06/fonts/fonts') from within your script.
Best

joeupright
Posts: 11
Joined: Thu Feb 24, 2011 11:20 pm

Re: How do I install GhostScript on IBMi?

Post by joeupright » Wed Aug 14, 2013 6:27 pm

Hello,

Well, we tried to install this last Friday (08-09-2013) afternoon and failed. We ran into numerous issues and ended up aborting the install and are going to use an alternate method.

The 2 main errors encountered that kept repeating:
mntctl() failed to return fugger size: A system call received a parameter that is not valid
group system does not exist - using root

I am not sure what either refers to and the CIO did not like this, so we decided to abort the install and will not be moving forward with it.

Thank you for trying to assist.

erich_hieden
Posts: 393
Joined: Tue Jul 07, 2009 9:01 am

Re: How do I install GhostScript on IBMi?

Post by erich_hieden » Mon Aug 19, 2013 8:42 am

Hello Joe

Sorry to hear that. That's the script I used to install ghostscript on my own and several customer machines. You do have access to the internet from your IBM i (including DNS resolving), don't you?

Would you mind telling a little bit about the alternative method you're going to use instead? I'm currently looking for alternative pdf handling on ibm i as well.

Best

jeff4593
Posts: 2
Joined: Sat Aug 24, 2013 3:17 pm

Re: How do I install GhostScript on IBMi?

Post by jeff4593 » Sat Aug 24, 2013 3:22 pm

I am new to this form and followed all the instructions and it all worked fine. I am ready to install GS and need the wwwinstallgs. Where can I get this script

erich_hieden
Posts: 393
Joined: Tue Jul 07, 2009 9:01 am

Re: How do I install GhostScript on IBMi?

Post by erich_hieden » Mon Aug 26, 2013 8:47 am

PM me your email address and i will send wwwinstallgs.sh to you directly.

jeff4593
Posts: 2
Joined: Sat Aug 24, 2013 3:17 pm

Re: How do I install GhostScript on IBMi?

Post by jeff4593 » Thu Sep 12, 2013 2:06 am

I don't seem to have permission to do a PM so here is my email address jdwhitt at earthlink dot net.

mark397
Posts: 87
Joined: Thu May 30, 2013 6:12 pm

Re: How do I install GhostScript on IBMi?

Post by mark397 » Fri Oct 04, 2013 9:27 pm

Something you might be interested in, copy and paste this into Google:
Creating high quality thumbnails for PDFs in Linux using Imagemagick

A friend of mine swears that imagemagick/imagick is incapable of making high quality thumbnails for PDF's, and says he has the fix for it. The post says it runs on Linux, but it should work on an iSeries with Zend if you enable the imagick plugin.

erich_hieden
Posts: 393
Joined: Tue Jul 07, 2009 9:01 am

Re: How do I install GhostScript on IBMi?

Post by erich_hieden » Mon Oct 07, 2013 7:40 am

You can easily create thumbnails out of PDF using PHP and Imagick (which needs Ghostscript to do this). The important part is to add the pagenumber in square brackets when reading the PDF.

Basic example:

Code: Select all

$imagick = new Imagick();

$imagick->readImage("/tmp/example.pdf[0]");  //Read only first page -> [0]

$imagick->setImageDepth(8);
$imagick->setImageColorSpace(Imagick::COLORSPACE_RGB);
$imagick->setImageFormat('jpeg');

$imagick->scaleImage($new_width, $new_height);

$imagick->writeImage("/tmp/thumbnail.jpg");
Best

kuke435
Posts: 1
Joined: Tue Oct 15, 2013 2:58 pm

Re: How do I install GhostScript on IBMi?

Post by kuke435 » Tue Oct 15, 2013 3:04 pm

Hello,
interesting that ghostscript and the iSeries install with help of perzl dot org.
Can you please upload the "wwwinstallgs dot sh" as "wwwinstallgs dot sh dot txt" ?
Thank you

Post Reply