将pdf转换为jpg,将jpeg转换为缩略图

I have written code for converting pdf to jpeg and its working fine but what option should I pass to create thumbnail in the exec();(for width and height purpose). here I am getting. I have tried -dDEVICEWIDTHPOINTS=100 -dDEVICEHEIGHTPOINTS=200 option but it seems invalid arguments.

following is my code:

 //include 'thumbcreator.php';
 ini_set('display_errors', 1);
 $pdf='example.pdf';
 $quality=90;
 $res='300x300';
 $exportName="pdf_export_" . time();
 $exportPath=realpath(dirname(__FILE__))."/$exportName/fullres/%03d.jpg";
 $exportPaththumb=realpath(dirname(__FILE__))."/$exportName/fullresthumb/%03d.jpg";

 mkdir(realpath(dirname(__FILE__))."/$exportName");
 mkdir(realpath(dirname(__FILE__))."/$exportName/fullres");
 mkdir(realpath(dirname(__FILE__))."/$exportName/fullresthumb");
 set_time_limit(900);
 exec("'gs' '-dNOPAUSE' '-sDEVICE=jpeg' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4' '-o$exportPath' '-r$res' '-dJPEGQ=$quality' '$pdf'",$output);
 exec("'gs' '-dNOPAUSE' '-sDEVICE=jpeg' '-dUseCIEColor' '-dTextAlphaBits=4' '-dGraphicsAlphaBits=4','-dDEVICEWIDTHPOINTS=100 -dDEVICEHEIGHTPOINTS=200' '-o$exportPaththumb' '-r$res' '-dJPEGQ=$quality' '$pdf'",$output);

 for($i=0;$i<count($output);$i++){
             echo($output[$i] .'<br/>');
 }

Any help will be appreciated. Thanks in advance :).

Why do you think DEVICEWIDTHPOINTS and DEVICEHEIGHTPOINTS are invalid arguments ?

You haven't set -dFIXEDMEDIA so the initial values can be overriden by media requests from the input. You probably will also want to set -dPDFFitPage in order to scale the PDF input to fit on the declared media size, if you don't do that, then you'll just get the bottom left corner of the input rendered.

Don't set -r when using this, the resolution will have to be recalculated in order to scale the input into the fixed size media you have requested. (Note that you have requested the media in points, 1/72 inch)

Please don't use -dUSECIEColor, that's a horrible hack from the PostScript world. Unless you know precisely what you are doing, that will result in worse colour management.