Page 1 of 2
Convert PDF to JPG using ASP classic
Posted: 2008-09-02T15:45:20-07:00
by smitho
I'm having not luck getting imagemagick to convert pdfs to jpg using ASP.
I'm working on XPPro IIS 5.1 ASP classic. I've installed the latest version of imagemagick to:
C:\Inetpub\wwwroot\myTest\ImageMagick
I have a pdf file sitting in the following folder:
C:\Inetpub\wwwroot\myTest\files
If I open the cmd window and run C:\>convert C:\Inetpub\wwwroot\myTest\files\test.pdf C:\Inetpub\wwwroot\myTest\f
iles\test.jpg The pdf is converted to a jpg.
I create an ASP page called image.asp within the C:\Inetpub\wwwroot\myTest folder:
Code: Select all
<%
Set Img = Server.CreateObject("ImageMagickObject.MagickImage.1")
Img.Convert "C:\Inetpub\wwwroot\myTest\files\test.pdf", "C:\Inetpub\wwwroot\myTest\files\test.jpg"
%>
The page does not give me any errors but it also does not convert the pdf to jpg.
Any suggestions as to how to make this work would be greatly appreciated.
Re: Convert PDF to JPG using ASP classic
Posted: 2008-09-02T16:07:33-07:00
by magick
ImageMagick utilizes the Ghostscript delegate program (gswin32c.exe) to interpret PDF documents. Chances are this is not working in your ASP environment. You can add "-verbose" to your command line to discover to find out the exact command ImageMagick is trying to execute.
Re: Convert PDF to JPG using ASP classic
Posted: 2008-09-02T16:16:10-07:00
by smitho
Thanks magick I tried:
Img.Convert "-verbose","C:\Inetpub\wwwroot\myTest\files\test.pdf", "C:\Inetpub\wwwroot\myTest\files\test.jpg"
but still nothing.
I've also tried:
Code: Select all
<%
Option Explicit
Dim mytest, WshShell, oExec
mytest = "C:\Inetpub\wwwroot\myTest\ImageMagick\convert C:\Inetpub\wwwroot\myTest\files\test.pdf C:\Inetpub\wwwroot\myTest\files\test.jpg "
Set WshShell = Server.CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(mytest)
Do While oExec.Status = 0
'WshShell.Sleep 100
Loop
Set oExec = Nothing
Set WshShell = Nothing
%>
Is what I'm trying to do possible? I've used imagemagick previously with PHP and worked like a dream, unfortunately I don't have PHP as any option here.
Re: Convert PDF to JPG using ASP classic
Posted: 2008-09-04T21:14:00-07:00
by smitho
Just tried this:
Code: Select all
<%
Set Img = Server.CreateObject("ImageMagickObject.MagickImage.1")
Img.Convert "-verbose","C:\Inetpub\wwwroot\myTest\files\test.jpg", "C:\Inetpub\wwwroot\myTest\files\test.gif"
%>
and I got a gif version of the file so it is working.
magick is there anyway to "utilize the Ghostscript delegate program (gswin32c.exe)" to interpret the PDF docs?
Any suggestions would be appreciated.
Re: Convert PDF to JPG using ASP classic
Posted: 2009-04-06T19:30:36-07:00
by daveabad
Having the exact same issue... I can use asp/com to convert a png or gif to a jpg but not a pdf. And adding the verbose parameter provides no clues.
Any ideas on how to configure ghostscript to work with the com object would be greatly appreciated.
Thanks.
Dave
Re: Convert PDF to JPG using ASP classic
Posted: 2009-05-05T19:16:55-07:00
by daveabad
Not sure of your applications for the pdf to jpg conversion but have a look at the process monitor on the server when you run the conversion on the command line. I found it was pegging one of my server's cpu's. This solution might not be suitable for production.
Re: Convert PDF to JPG using ASP classic
Posted: 2009-05-20T18:51:40-07:00
by Wkidd
Same problem.
Version
1. ImageMagick version 6.5.2-7-Q16
2. ghostscript version 8.64
3. Win XP Pro SP3
I have tried to convert a PDF to a JPEG image but nothing happen.
Command Line Test : It's OK.
Code: Select all
C:>Convert -density 300 test.pdf test.jpg
ASP Test :Nothing happen.
Code: Select all
<%
Set Img = Server.CreateObject("ImageMagickObject.MagickImage.1")
Img.Convert "test.gif", "test.jpg" ' OK
Img.Convert "-density", "300", "test.pdf", "test2.jpg" ' Nothing happen
%>
Ghostscript test : It's OK.
Code: Select all
gswin32c -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -EPSCrop -dAlignToPixels=0 -dGridFitTT=0 -sDEVICE=pnmraw -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300x300 -dUseCIEColor -dFirstPage=1 -dLastPage=1 -sOutputFile=test3.jpg test.pdf
Command Line with verbose: It's OK.
Code: Select all
C:\Program Files\ImageMagick-6.5.2-Q16>convert -density 300 -verbose test.pdf test.jpg
[ghostscript library] Files/gs/gs8.64/bin/gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-4ga3VlFr" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-iu4qWdp1" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-5uxeMnYs"C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-4ga3VlFr PNM 1100x660 1100x660+0+0 8-bit DirectClass 2.077mb test.pdf PDF 1100x660 1100x660+0+0 16-bit DirectClass 2.077mb test.pdf=>test.jpg PDF 1100x660 1100x660+0+0 16-bit DirectClass 32kb 0.063u 0:01
Any help pls ...
Re: Convert PDF to JPG using ASP classic
Posted: 2009-05-21T06:31:09-07:00
by magick
Does your command work from the command line? Open a Command Prompt window and enter your command. What happens?
Re: Convert PDF to JPG using ASP classic
Posted: 2009-05-21T06:45:58-07:00
by Wkidd
Yes, I did.
Everthing is ok with command line that I already mentioned on previous post except ASP program.
Re: Convert PDF to JPG using ASP classic
Posted: 2009-05-21T06:59:31-07:00
by magick
Ok, its your ASP environment, perhaps a security restriction or a problem loading a DLL. Hopefully a Windows developer will help. The ImageMagick developers do not work with ASP so we cannot help you.
Re: Convert PDF to JPG using ASP classic
Posted: 2009-08-19T03:49:55-07:00
by meyca
Hi everyone,
has someone been able to resolve the issue? We are experiencing the same problem and would love to hear some hints on that issue.
Any comment is welcome!
Regards
Carsten
Re: Convert PDF to JPG using ASP classic
Posted: 2009-11-20T10:33:28-07:00
by kdc415
Did anyone get this working? Having the same problem. Tried on command line and I discovered that ghostscript did not get installed. Will sort that out first.
Re: Convert PDF to JPG using ASP classic
Posted: 2009-11-20T12:06:52-07:00
by kdc415
I got the latest GhostScript from the delegates download folder, installed that and reinstalled IM and I'm still not showing pdf listed as a delegate. I thought the installs took care of the mappings, but I guess the config files and registry need to be edited? Anyone know?
Re: Convert PDF to JPG using ASP classic
Posted: 2010-12-03T01:11:08-07:00
by nitech
Does really nobody have an answer to this question? I face the same issue:
- Been using Imagemagick on my IIS6-server for many years. Working flawlessly.
- Installed Ghostscript
- VBS-script and command line can now convert PDF to JPEG or similar - but doesn't work from .ASP-file
I suspect Ghostscript is using a temp folder or trying to write to some kind of location which it has not write access. Imaegmagick for instance uses c:\windows\temp as a temporary storage during execution.
I've tried process monitor, but I cannot distinguish the difference between vbscript execution from vbs-file vs asp-file.
Any ideas? Should we be looking a Ghostscript forums for help?
Another thing: -verbose does not give me any additional info when executing from COM-object inside .asp-file.
Re: Convert PDF to JPG using ASP classic
Posted: 2011-06-01T01:38:31-07:00
by fredoche
Hello
Did someone find a solution ?
I have exactly the same problem after migrating on a brand new platform with IIS7-2008R2
I'm using latest versions of ghostscript and imagemagick object. Everything works well with command line and .vbs scripts, PDFs manipulations work, but in ASP, it doesn't.
No error message, nothing, even if I use wrong paths as parameter for example, very surprising...
With ASP other formats (jpg,png...) than PDF work flawlessly
Thanks in advance if you have any clue
Fred