Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Ghostscript #220

Closed
StaggerLeee opened this issue Feb 16, 2017 · 32 comments
Closed

Ghostscript #220

StaggerLeee opened this issue Feb 16, 2017 · 32 comments

Comments

@StaggerLeee
Copy link

How to install Ghostscript together with ImageMagick on Neard ?
Is it possible to add it to Neard as Tools module ?
ImageMagick is installed and detected well of course.

https://www.ghostscript.com/

I need it for new PDF thumbnails manipulation, now in core of WordPress 4.7 and above versions.

Thanks for any answer.

@crazy-max
Copy link
Member

Hi,

I will take a look on your suggestion!
Thanks!

@StaggerLeee
Copy link
Author

Thank you. It is for your benefit also, considering how many WordPress installations are out there. (developing needed for each new one)

You decide if issue will be closed.

@crazy-max crazy-max self-assigned this Apr 20, 2017
@crazy-max crazy-max added this to the neard-1.3 milestone Apr 20, 2017
crazy-max pushed a commit to neard/modules-untouched that referenced this issue Jul 22, 2017
crazy-max pushed a commit to neard/module-ghostscript that referenced this issue Jul 23, 2017
crazy-max pushed a commit that referenced this issue Jul 23, 2017
crazy-max pushed a commit to neard/neard.github.io that referenced this issue Jul 23, 2017
@crazy-max
Copy link
Member

Ghostscript is available in the latest 1.2.16 unstable release

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 2, 2017

Thank you for Ghostscript support.
Problem is I still cannot it make to work. Do you have time for some short manual ? Or any better to install WordPress and try to generate PDF thumbnails from them.

I uninstalled my Imagemagick and Ghostscript I installed in Windows 10. Before it with some mixing of different tutorials made it to work.

Now not anymore. Do some lines need to be added in PHP, Apache conf files ?

Tools - ImageMagick & Ghostscript console(s) are executed fine.
Added right Enviroment Variables in both "paths".

Image of Yaktocat

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 2, 2017

Anyway, cannot lose more time on it as it is just localhost testing. Hosting servers probably have all configured, so no need to worry about it.

I managed somehow via this tutorial:
https://kau-boys.de/3194/adventskalender/pdf-vorschaubilder-von-wordpress-4-7-in-xampp-unter-windows-verwenden

Just installed both ImageMagick and Ghostscript Windows exe inside Neard folder, to have all in one place. And adjusted windows enviroment paths accordingly.

This WordPress plugin complains same thing, but Ghostscript is now making PDF thumbnails.
Seems strange, but this part in tutorial about copying all .dll files from ImageMagick-x.x.x-x-vc14-x86.zip, to D:\Neard\bin\apache\apache2.4.27\bin is crucial. Without this I cannot make Ghostscript to work, no matter what.

Anyway, just a bit info for other Neard Users who want it activated on localhost.
Drag this link via Google translate and follow steps.

PS: Just to add, I never trusted this plugin. And it showed itself it is not to be trusted when detecting. Any time I changed something in servers, Windows configuration I restarted servers and tried to generate PDF thumbnails again.

@crazy-max
Copy link
Member

Hi @StaggerLeee,

Thanks for your feedback about Ghostscript and Imagick!
Can you please open a new issue for your problem ?

Thnks for your contrib!

@StaggerLeee
Copy link
Author

Hi @crazy-max,

I cannot open new issue as I am not sure if I understand roles of ImageMagick and Ghostscript in Neard. I do not know is it, as it is now, by fashion, or what.

Are those 2 tools in Neard supposed to work with Apache, PHP on default ? Without any tweaking. Now I am not sure it is possible.
Or they are just 2 additional tools as side help, separate from servers.

@crazy-max
Copy link
Member

@StaggerLeee Yes they are supposed to work with Apache and PHP as they are included in the env var PATH to work with.

If you go to http://localhost/?p=phpinfo, you can check that imagick extension is loaded :

image

I have installed the latest release of Wordpress to check your issue but can you tell me where i can find the page "PDF Thumbnails Support test" on Wordpress ?

@crazy-max
Copy link
Member

Ok i have found the PDF Thumbnails Support Test plugin!

image

@StaggerLeee
Copy link
Author

Dont trust blindly this plugin. It has problem detecting Ghostscript in some cases.
ethanclevenger91/pdf-thumbnails-support-test#1

Go to the Media Manager and simply upload a PDF. For 2 second you will see if Ghostscript is working on server. If there is no PDF thumbnail, it does not work.

@crazy-max
Copy link
Member

Ok the problem is that PDF Thumbnails Support Test plugin is Linux specific.
After investigate on the source code of the plugin, it checks :

  • ImageMagick: convert -v : KO on my computer because convert is loaded from C:\Windows\System32\convert.exe instead of neard\tools\imagemagick\
  • Imagick: extension_loaded('imagick') : OK here
  • Ghostscript: which gs instead of where gswin32c.exe for Windows.

@crazy-max
Copy link
Member

crazy-max commented Sep 3, 2017

Ok, after changing some things on Neard, ImageMagick is now OK :

image

In the file neard\core\classes\class.win32service.php replace lines 148-157 with :

if ($this->getNssm() instanceof Nssm) {
    $nssmEnvPath = Util::getAppBinsRegKey(false);
    $nssmEnvPath .= Util::getNssmEnvPaths();
    $nssmEnvPath .= '%SystemRoot%/system32;';
    $nssmEnvPath .= '%SystemRoot%;';
    $nssmEnvPath .= '%SystemRoot%/system32/Wbem;';
    $nssmEnvPath .= '%SystemRoot%/system32/WindowsPowerShell/v1.0';
    $this->getNssm()->setEnvironmentExtra('PATH=' . $nssmEnvPath);
    return $this->getNssm()->create();
}

I will create a new issue for this.

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 3, 2017

Thing is I cannot make it to work in Neard unless I put all .dll files in active Apache bin folder.
D:\Neard\bin\apache\apache2.4.27\bin

ImageMagick .dll files from here: http://windows.php.net/downloads/pecl/deps/

Or I make something wrong totally.

As I see all those .dll files are not inside ImageMagick & Ghostscript folders inside tools folder. Need to download them and put inside apache bin folder.

@crazy-max
Copy link
Member

@StaggerLeee Can you post a screenshot of imagick section in your phpinfo (http://localhost/?p=phpinfo) ?

image

I think i have found an issue with ImageMagick supported formats = no value.

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 3, 2017

I have "formats", as Ghostscript is installed "outside" Neard and recognized right. (Or maybe I have formats because ImageMagick is isntalled "outside" Neard too. Outside means for Windows, under parantheses just because I installed exe inside Neard folder, but it really means/change nothing.)
Maybe you dont know. ImageMagick cannot alone generate thumbnails from PDF files. Ghostscript is needed for that.

Image of Yaktocat

@crazy-max
Copy link
Member

Yep i know Ghostscript is required but i have to figure out why i don't have all these ImageMagick supported formats like you ;)

What files have you added in apache/bin please ?

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 3, 2017

I wrote above. I installed ImageMagick too as imagine there is none in Neard. Maybe that windows installation and enviroment paths added formats. Do not know now for sure, it is really complicated. To many steps to get it to work.
(This reason is precisely mainly reason I asked from you to add Ghostscript in Neard on default, It is really headache to install and configure all to make it work, so some Neard native and default solution would be very perfect)

dll files inside (copied to) active Apache bin folder are all .dll files from this ZIP:
http://windows.php.net/downloads/pecl/deps/ImageMagick-6.9.3-7-vc14-x86.zip

(VC14 - x86. From bin folder in this ZIP, all dll files)

@crazy-max
Copy link
Member

Ok i see, there are missing dlls with the current imagick extension (3.4.3). Only these DLLs are included in neard\bin\php\php7.1.8\imagick :

image

I have to include the deps from PECL like you said.

@crazy-max
Copy link
Member

Confirmed, i have forgot PECL deps :

image

@crazy-max
Copy link
Member

Now formats are loaded :

image

By copying everything from ImageMagick-6.9.3-7-vc14-x86.zip to neard\bin\php\php7.1.8\imagick.

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 3, 2017

Let me uninstall ImageMagick & Ghostscript from Windows, remove their Enviroment Variables, remove .dll from Apache bin folder, and test with only this PECL dependency solution. Will be back shortly.

@crazy-max
Copy link
Member

@StaggerLeee Thanks for your support

@crazy-max
Copy link
Member

Ok now with Ghoscript when i try to use ImageMagick to convert PDF i've got this error :

C:\Users\crazy>C:\neard\bin\php\php7.1.8\imagick\convert.exe "C:\Users\crazy\Desktop\pdf-sample.pdf" test.png
convert.exe: UnableToOpenConfigureFile `delegates.xml' @ warning/configure.c/GetConfigureOptions/706.
convert.exe: FailedToExecuteCommand `"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72"  "-sOutputFile=C:/Users/crazy/AppData/Local/Temp/magick-96248uLsgd34j_Tf%d" "-fC:/Users/crazy/AppData/Local/Temp/magick-96245oyv3XDug7_O" "-fC:/Users/crazy/AppData/Local/Temp/magick-9624ut9X5XIe8DyZ"' (Le fichier spécifié est introuvable.) @ error/delegate.c/ExternalDelegateCommand/480.
convert.exe: PDFDelegateFailed `Le fichier spécifié est introuvable.' @ error/pdf.c/ReadPDFImage/801.
convert.exe: NoImagesDefined `test.png' @ error/convert.c/ConvertImageCommand/3252.

But if i rename gswin32c.exe to gs.exe in neard\tools\ghostscript\ghostscript9.21\bin , now it works like a charm :

image

@StaggerLeee
Copy link
Author

Yes it is working now, thank you.
For other Neard Users:

  • Download dependency package from this link, x86, V14, latest ImageMagick:
    http://windows.php.net/downloads/pecl/deps/

  • Everything inside "bin" folder in this ZIP copy into your PHP active folder/imagemagick subfolder (I did overwrite Neard files already in)

  • It is all, no tweaking with Windows and enviroment variables needed.

@crazy-max
Copy link
Member

To summary your issue, i have to :

  • Include PECL deps of ImageMagick in php\imagick
  • Copy gswin32c.exe to gs.exe

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 3, 2017

Put both those .exe (copies) in future releases, just to be sure. Not so big deal, they are small files:
gswin32c.exe and gs.exe
I wonder why I did not get same Ghostscript error. Just tested with PDF upload in WordPress. You do it from CMD console ?

Did you just extract whole ZIP content inside imagemagick PHP subfolder ?
When I did it it did not work. Had to extract content from ZIPs bin subfolder.

@crazy-max
Copy link
Member

Yep from CMD because gswin32c.exe does not redirect errors to stdout

@StaggerLeee
Copy link
Author

@crazy-max,

This is very important point for all Neard users using this. Even for me to understand it right, and not to do things by heart.

Did you just extract whole ZIP content inside imagemagick PHP subfolder ?
When I did it it did not work. Had to extract content from ZIPs bin subfolder.

@crazy-max
Copy link
Member

Yes the bin folder of course! (you can remove *.pdb files) :

image

In php\php7.1.8\imagick :

image

@crazy-max
Copy link
Member

I will create a new issue to explain everything

@N6REJ
Copy link

N6REJ commented Sep 4, 2017

I have loved following this discussion. Is the thumbnail generated automatically or is something else needed in html to make this happen? I'd love to see this in Joomla articles

@StaggerLeee
Copy link
Author

StaggerLeee commented Sep 4, 2017

In WordPress it is handled automatically when Ghostscript is detected. Plugin and third party code do not have to do anything special with code. Generating thumbnail. Themes still have to do a bit in code to call it, mostly to link it to the PDF file.

crazy-max added a commit to neard/neard.github.io that referenced this issue Nov 20, 2017
crazy-max added a commit that referenced this issue Nov 24, 2017
crazy-max added a commit to neard/modules-untouched that referenced this issue Nov 25, 2017
crazy-max added a commit to neard/module-ghostscript that referenced this issue Nov 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants