<?php
$file = get_attached_file( $attachment_id );
$output_format = "jpeg";
$antialiasing = "4";
$preview_page = "1";
$resolution = "300";
$output_file = 'srv/www/chetan/doc/' . $attachment_id . '_imagick_preview.jpg';
$exec_command = "gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=" . $output_format . " ";
$exec_command .= "-dTextAlphaBits=" . $antialiasing . " -dGraphicsAlphaBits=" . $antialiasing . " ";
$exec_command .= "-dFirstPage=" . $preview_page . " -dLastPage=" . $preview_page . " ";
$exec_command .= "-r" . $resolution . " ";
$exec_command .= "-sOutputFile=" . $output_file . " '" . $file . "'";
exec( $exec_command, $command_output, $return_val );
Related