Jump to content

ImageMagick COM Problem

Recommended Posts

I am having a very unique, but repeatable problem with ImageMagick COM interface. Here are the applicable lines of code:


and then later on...

$oIM.Convert(String($arFileList[$nFileIndex])&'[0]',"-alpha", "remove",@TempDir&"\temp.jpg")

the array points to a pdf file with the "convert" command converting the first page of the pdf to a jpg with any alpha layer removed.

Every time, without fail, the first time I run the script on a freshly booted machine it crashes on the $oIM.Convert command. It does this if it isn't compiled and says there is an error executing the command on the object. If compiled, i get an error that autoit has stopped responding. Anytime I run the script, compiled or not, after this initial crash everything works perfectly fine.

I am totally at a loss as to why this is occurring and how to correct it.

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

Hello probably you're using a version that has not support pdf to jpg. I think it requires Ghostscript. You can use Ghostscript directly from commandline.




Link to comment
Share on other sites

I do have GhostScript installed. The ImageMagick command works at all other times except the first time it is executed on a fresh boot.

Is there a way to convert a pdf to image with GhostScript command lines?

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

I did a script time ago where I needed to convert pdf files to png. I tried with ImageMagick but it failed if it wasn't installed on the computers where the script was going to work.

I finally ended using a command line program included in the xpdf called pdftopng.

pdftopng version 3.04
Copyright 1996-2014 Glyph & Cog, LLC
Usage: pdftopng [options] <PDF-file> <PNG-root>
  -f <int>          : first page to print
  -l <int>          : last page to print
  -r <int>          : resolution, in DPI (default is 150)
  -mono             : generate a monochrome PBM file
  -gray             : generate a grayscale PGM file
  -freetype <string>: enable FreeType font rasterizer: yes, no
  -aa <string>      : enable font anti-aliasing: yes, no
  -aaVector <string>: enable vector anti-aliasing: yes, no
  -opw <string>     : owner password (for encrypted files)
  -upw <string>     : user password (for encrypted files)
  -q                : don't print any messages or errors
  -cfg <string>     : configuration file to use in place of .xpdfrc
  -v                : print copyright and version info
  -h                : print usage information
  -help             : print usage information
  --help            : print usage information
  -?                : print usage information

You can also take a look at nconvert , from the same guys that did Xnview. It can do a lot of image processing from the command line without having to install anything.

If you can not directly convert from pdf to jpg with nconvert, maybe you can do a pdf to png with pdftopng and later png to jpg with nconvert.

Check the license of both programs to see if they match with any possible comercial use of your script.

If you need examples of cmd calling of both programs, just ask for it.

Greets from Barcelona

Edited by Qwerty212
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...