OpenSencillo  2015.002
PDFtoJPG Class Reference

Public Member Functions

 convert ($name, $id=null, $pdfSource=null, $jpgOutDir=null, $quality=null)
 simulation ($name, $id=null, $pdfSource=null)
 pdfPathGenerator ($name, $id=null, $pdfSource=null)
 errorList ()
 inPath ($path)
 outPath ($path)

Data Fields

 $error = array()
 $path = array()

Private Attributes

 $j

Detailed Description

Definition at line 2 of file imagick.convert.pdf2jpg.php.


Member Function Documentation

convert ( name,
id = null,
pdfSource = null,
jpgOutDir = null,
quality = null 
)

Convert PDF to JPG via PHP imagick

Parameters:
string$name(name input file)
number$id(numeric user id if system using id)
string$pdfSource(pdf source path)
string$jpgOutDir(jpg out root dir path)
Returns:
number

Definition at line 18 of file imagick.convert.pdf2jpg.php.

        {
            ignore_user_abort(true);
            $id = ($id === null ? 'Guests' : $id);
            $pdfSource = ($pdfSource === null ? './' : $pdfSource);
            $jpgOutDir = ($jpgOutDir === null ? './' : $jpgOutDir);
            $quality = ($quality === null ? 100 : $quality);
            
                $imagick = new Imagick();
                chmod($pdfSource,0777);
                chmod($jpgOutDir,0777);
                //rmdir($jpgOutDir."/user$id");
                mkdir($jpgOutDir."/user$id",0777);
                rmdir($jpgOutDir."/user$id/$name");
                mkdir($jpgOutDir."/user$id/$name",0777);
                chmod($jpgOutDir."/user$id/",0777);
                chmod($jpgOutDir."/user$id/$name/",0777);

                $i=0;
                $this->j=1;
                while($i<1000)
                {
                        $this->outPath($jpgOutDir."/user".$id."/".$name."/".$name."[".$i."].jpg");
                        try
                        {
                                $imagick->setResolution(144,144);
                                $imagick->readImage($this->inPath($pdfSource."/user".$id."/".$name."[".$i."]"));
                                //$imagick->setCompression(Imagick::COMPRESSION_JPEG);
                                $imagick->setImageCompressionQuality($quality);
                                //$resolution=$imagick->getImageResolution();
                                //$imagick->scaleImage(0,1000);
                                
                                //$imagick->setImageDepth(600);
                                $imagick->writeImage($this->outPath($jpgOutDir."/user".$id."/".$name."/".$name."[".$i."].jpg"));
                                $this->j++;
                        }
                        catch(Exception $e)
                        {
                                $this->error[$i] = $e;
                                $this->error['message'] = 'Imagick Exception: '.$e;
                                break;
                        }
                        $i++;
                }
                return $this->j;
        }
errorList ( )

Get last error

Definition at line 123 of file imagick.convert.pdf2jpg.php.

        {
                return $this->error;
        }
inPath ( path)

Path finder for testing

Parameters:
string

Definition at line 132 of file imagick.convert.pdf2jpg.php.

        {
            $this->path['in'] = $path;
                return $path;
        }
outPath ( path)

Path finder for testing

Parameters:
string

Definition at line 142 of file imagick.convert.pdf2jpg.php.

        {
            $this->path['out'] = $path;
            return $path;
        }
pdfPathGenerator ( name,
id = null,
pdfSource = null 
)

Convert simulation for generate path to source. Without ImageMagic php extension.

Parameters:
string$name(name input file)
number$id(numeric user id if system using id)
string$pdfSource(pdf source path)
Returns:
mixed

Definition at line 111 of file imagick.convert.pdf2jpg.php.

        {
                $id = ($id === null ? 'Guests' : $id);
                $pdfSource = ($pdfSource === null ? './' : $pdfSource);
                
                return array('maxPage'=>'unknown',
                                         'minPage'=>'unknown',
                                         'source'=>$pdfSource."/user".$id."/".$name);
        }
simulation ( name,
id = null,
pdfSource = null 
)

Convert simulation

Parameters:
string$name(name input file)
number$id(numeric user id if system using id)
string$pdfSource(pdf source path)
Returns:
mixed

Definition at line 74 of file imagick.convert.pdf2jpg.php.

        { 
                $id = ($id === null ? 'Guests' : $id);
                $pdfSource = ($pdfSource === null ? './' : $pdfSource);
                 
                $imagick = new Imagick();       
                
                $i=0;
                $this->j=1;
                while($i<1000)
                {
                        try
                        {
                                $imagick->readImage($this->inPath($pdfSource."/user".$id."/".$name."[".$i."]"));
                                $this->j++;
                        }
                        catch(Exception $e)
                        {
                                break;
                        }
                        $i++;
                }
                return array('maxPage'=>$this->j,
                                         'minPage'=>0,
                                         'source'=>$pdfSource."/user".$id."/".$name);
        }

Field Documentation

$error = array()

Definition at line 4 of file imagick.convert.pdf2jpg.php.

$j [private]

Definition at line 6 of file imagick.convert.pdf2jpg.php.

$path = array()

Definition at line 5 of file imagick.convert.pdf2jpg.php.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables