Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:29:46+00:00 2026-06-12T18:29:46+00:00

I am trying to convert PDF to JPG file with this code: $pdf_file =

  • 0

I am trying to convert PDF to JPG file with this code:

$pdf_file = 'text.pdf';
$save_to = 'demo.jpg'; //make sure that apache has permissions to write in this folder! (common problem)
//execute ImageMagick command 'convert' and convert PDF to JPG with applied settings
exec('convert '.$pdf_file.' '.$save_to, $output, $return_var);

if($return_var == 0) { //if exec successfuly converted pdf to jpg
print "Conversion OK";
}
else print "Conversion failed.<br />".$output;

And I get message Conversion OK but image file don’t creates. When I tried this on the different server, then everything works.
Permissions for root catalog are set to 777. I don’t have any idea why it doesn’t work… I don’t know which versions of Imagemagick are installed on both servers. Maybe that is the problem ? In phpinfo() there is no information about version or anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:29:47+00:00Added an answer on June 12, 2026 at 6:29 pm

    You are having trouble running “convert” because the PHP function exec() has been disabled in your php.ini file.

    When a exec() command is failing there are multiple steps that can be taken to troubleshoot the problem:

    1. Verify if safe mode is on. Specifically the docs say:

      Note: When safe mode is enabled, you can only execute files within the
      safe_mode_exec_dir. For practical reasons, it is currently not allowed
      to have .. components in the path to the executable.

    2. Turn on Error Reporting too see if that gives any more information. This can be accomplished by adding code like the following to the top of your script:

      ini_set('display_errors', 1);
      ini_set('error_reporting', E_ALL);
      
    3. Simplify the exec() command to something that should always work:

      exec('/bin/echo helloWorld',$output);
      var_dump($output);
      

    In your specific case when you tried step #3 above, it returned null. Null is what PHP returns when the exec() function is disabled. Also, if you were able to turn on error reporting (step #2) the output would have looked something like the following:

    PHP Warning:  exec() has been disabled for security reasons in /home/path/to/file.php on line 2
    NULL
    

    The solution to this problem is to enable the exec function in php.ini or go to a host/server that allows the function to be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to convert this c code into MIPS and run it in SPIM. int
I am trying to use ghostscript to convert a pdf to jpg from inside
I am trying to convert image file (jpeg) in to pdf file in my
I am trying to convert a PDF to JPEG: $ convert pdf-test.pdf pdf-test.pdf.jpg However,
I'm trying to convert PDF to IMG (JPG) with help PHP. I'm using imagick
I'm trying to convert the math presented on this paper: http://www.bouncingchairs.net/pskalman-lategecco.pdf Around page 3
I am trying to convert a PDF to a JPG with a PHP exec()
I'm trying to convert this delimited PDF to an excel (or some other delimited
I am trying to convert a multi-page PDF file into a bunch of JPEGs,
please bear with my newbie questions.. I was trying to convert PDF to PNG

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.