Posted by ajay1kumar1 on July 2, 2010 at 10:52am
i made a separate module for add my additional process.
<?php
// Hook into the convert PDF to images and save it in database.
function convert_nodeapi($node, $op){ //echo $node->type;die;
if( ($op == 'insert' || $op == 'update') && $node->type == 'magazine'){
// echo "
"; print_r($node->field_pdf[0]);echo "
";echo $node->nid;
$fid = $node->field_pdf[0]['fid']; // Source file id
$uid = $node->field_pdf[0]['uid']; // user id
$nid = $node->nid; // node id
$cdir = "sites/default/files/nodes/".$nid."/"; // current directory
// Create node directory if it is not exists //
if(!is_dir("sites/default/files/nodes/".$nid))
{
exec("mkdir sites/default/files/nodes/".$nid);
}
// Convert pdf to png file in its node specified like sites/default/files/nodes/2/page.png //
$w = 500;
$args = array(0 => '-thumbnail '.$w);
_imageapi_imagemagick_convert($node->field_pdf[0]['filepath'], "sites/default/files/nodes/".$nid ."/page.png", $args) ;
//exec("convert -density 400 ".$node->field_pdf[0]['filepath']. " -scale 1000x500 sites/default/files/nodes/".$nid ."/page.png");
// Read all converted files from newly created node directory //
db_query("DELETE from {mag.convert_pdf} WHERE fid='".$fid."'");
if ($handle = opendir("sites/default/files/nodes/".$nid)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
db_query("INSERT INTO {mag.convert_pdf} (nid ,fid ,file_name ,cpath ,full_path ,updated)VALUES ( '".$nid."', '".$fid."', '".$file."', '".$cdir."', '".$cdir.$file."',CURRENT_TIMESTAMP);");
}
}
closedir($handle);
}
}
}
There is no setting you have to place in imagemagick with drupal 6.17 (i am using ubuntu OS), Just install imagemagick and configure (if req.)
Enjoy.......... Cheers
Ajay singh rathore.
