Ejemplo n.º 1
2
 function cdm_thumbPdf($pdf)
 {
     if (class_exists('imagick')) {
         $upload_dir = wp_upload_dir();
         $tmp_folder = $upload_dir['basedir'] . '/imageMagick_tmp/';
         if (!is_dir($tmp_folder)) {
             mkdir($tmp_folder, 0777);
         }
         $tmp = $tmp_folder;
         $format = "png";
         $source = $pdf;
         $dest = "" . $pdf . "_big.{$format}";
         $dest2 = "" . $pdf . "_small.{$format}";
         // read page 1
         $im = new imagick('' . $source . '[0]');
         // convert to jpg
         $im->setImageColorspace(255);
         $im->setImageFormat($format);
         //resize
         $im->resizeImage(650, 650, imagick::FILTER_LANCZOS, 1);
         //write image on server
         $im->writeImage($dest);
         //resize
         $im->resizeImage(250, 250, imagick::FILTER_LANCZOS, 1);
         //write image on server
         $im->writeImage($dest2);
         $im->clear();
         $im->destroy();
     } else {
         echo 'php-image-magick not installed. Please disable the pdf thumbnail options or install the php extention correctly.';
         exit;
     }
 }
Ejemplo n.º 2
0
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = get_temp_dir();
     $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ';
     $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
     $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
     $export = 'export HOME=/' . $tmpDir;
     shell_exec($export . "\n" . $exec);
     //create imagick object from pdf
     try {
         $pdf = new \imagick($absPath . '.pdf' . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         unlink($absPath);
         unlink($absPath . '.pdf');
         \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($absPath . '.pdf');
     return $image->valid() ? $image : false;
 }
Ejemplo n.º 3
0
function pdftojpg($pdfFile, $jpgFile)
{
    /*  
     * imagemagick and php5-imagick required 
     * 
     * all options for imagick: 
     *           http://php.net/manual/fr/class.imagick.php 
     * 
     */
    $pdf_file = $pdfFile;
    $save_to = $jpgFile;
    $img = new imagick();
    //this must be called before reading the image, otherwise has no effect - "-density {$x_resolution}x{$y_resolution}"
    //this is important to give good quality output, otherwise text might be unclear
    $img->setResolution(200, 200);
    //read the pdf
    $img->readImage("{$pdf_file}[0]");
    //reduce the dimensions - scaling will lead to black color in transparent regions
    $img->scaleImage(1920, 1080);
    //set new format
    $img->setCompressionQuality(80);
    $img->setImageFormat('jpg');
    // -flatten option, this is necessary for images with transparency, it will produce white background for transparent regions
    $img = $img->flattenImages();
    //save image file
    $img->writeImages($save_to, false);
    //clean
    $img->clear();
    $img->destroy();
}
Ejemplo n.º 4
0
 public function processPdf($fileNames)
 {
     $mpdf = Yii::app()->ePdf->mpdf();
     $mpdf->SetImportUse();
     $pagecount = $mpdf->SetSourceFile('../' . $fileNames['pdf']);
     if ($pagecount > 3) {
         for ($i = 1; $i <= 3; $i++) {
             if ($i != 1) {
                 $mpdf->AddPage();
             }
             $import_page = $mpdf->ImportPage($i);
             // add last 3 page
             $mpdf->UseTemplate($import_page);
         }
     } else {
         $tplId = $mpdf->ImportPage($pagecount);
         $mpdf->UseTemplate($tplId);
     }
     $mpdf->Output('../' . Extensions::FILE_PDF_PREVIEW_PATH . $fileNames['pdfPreview'], 'F');
     $im = new imagick();
     $im->readimage('/home/notesgen/public_html/' . Extensions::FILE_PDF_PREVIEW_PATH . $fileNames['pdfPreview']);
     $im->setImageCompressionQuality(0);
     $im->setImageFormat('jpeg');
     $im->writeImage('../' . Extensions::FILE_IMAGE_PATH . $fileNames['image']);
     $im->setImageCompressionQuality(80);
     $im->writeImage('../' . Extensions::FILE_IMAGE_PATH_APP . $fileNames['image']);
     $im->clear();
     $im->destroy();
 }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  */
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $this->initCmd();
     if (is_null($this->cmd)) {
         return false;
     }
     $absPath = $fileview->toTmpFile($path);
     $tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
     $defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
     $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
     $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
     shell_exec($exec);
     //create imagick object from pdf
     $pdfPreview = null;
     try {
         list($dirname, , , $filename) = array_values(pathinfo($absPath));
         $pdfPreview = $dirname . '/' . $filename . '.pdf';
         $pdf = new \imagick($pdfPreview . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         unlink($absPath);
         unlink($pdfPreview);
         \OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
         return false;
     }
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     unlink($absPath);
     unlink($pdfPreview);
     if ($image->valid()) {
         $image->scaleDownToFit($maxX, $maxY);
         return $image;
     }
     return false;
 }
Ejemplo n.º 6
0
 function thumbnail($file, $width = '120')
 {
     $name = $this->_dir . DS . $file . '[0]';
     $im = new imagick($name);
     $im->setImageFormat('jpg');
     $im->scaleImage($width, 0);
     header('Content-Type: image/jpeg');
     echo $im;
 }
Ejemplo n.º 7
0
function pdftoimage($file, $page)
{
    $filepart = pathinfo($file);
    $save_to = $filepart['filename'] . ".jpg";
    $im = new imagick($file[$page - 1]);
    $im->thumbnailImage(800, 0);
    $im->setImageFormat('jpg');
    $im = $im->flattenImages();
    file_put_contents($save_to, $im);
}
Ejemplo n.º 8
0
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     $tmpPath = $fileview->toTmpFile($path);
     //create imagick object from pdf
     try {
         $pdf = new \imagick($tmpPath . '[0]');
         $pdf->setImageFormat('jpg');
     } catch (\Exception $e) {
         \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
         return false;
     }
     unlink($tmpPath);
     //new image object
     $image = new \OC_Image($pdf);
     //check if image object is valid
     return $image->valid() ? $image : false;
 }
Ejemplo n.º 9
0
 public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
 {
     require_once 'PHPExcel/Classes/PHPExcel.php';
     require_once 'PHPExcel/Classes/PHPExcel/IOFactory.php';
     $absPath = $fileview->toTmpFile($path);
     $tmpPath = \OC_Helper::tmpFile();
     $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
     $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
     \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
     $phpexcel = new \PHPExcel($absPath);
     $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
     $excel->save($tmpPath);
     $pdf = new \imagick($tmpPath . '[0]');
     $pdf->setImageFormat('jpg');
     unlink($absPath);
     unlink($tmpPath);
     $image = new \OC_Image();
     $image->loadFromData($pdf);
     return $image->valid() ? $image : false;
 }
 public function generatePreviewImage($pdfFile, $saveTo)
 {
     try {
         $img = new imagick(Director::getAbsFile($pdfFile) . "[0]");
         //we only take first page
         // -flatten option, this is necessary for images with transparency, it will produce white background for transparent regions
         $img->setImageAlphaChannel(11);
         //Imagick::ALPHACHANNEL_REMOVE has been added in 3.2.0b2
         $img->mergeImageLayers(imagick::LAYERMETHOD_FLATTEN);
         //set new format
         //@Todo detect format from filename
         $img->setImageFormat('jpg');
         $img->setCompressionQuality(100);
         //save image file
         $img->writeImages($saveTo, false);
     } catch (\Exception $e) {
         error_log($e->getMessage());
         return false;
     }
     return true;
 }
Ejemplo n.º 11
0
 public function generatePdfImages($fileName, $filePages)
 {
     $pages = 0;
     $json = array();
     if (file_exists(DIR_DOWNLOAD . $this->config->get('msconf_temp_download_path') . $fileName)) {
         if (preg_match('/[^-0-9,]/', $filePages)) {
             $json['errors'][] = $this->language->get('ms_error_product_invalid_pdf_range');
         } else {
             $offsets = explode(',', $filePages);
             foreach ($offsets as $offset) {
                 if (!preg_match('/^[0-9]+(-[0-9]+)?$/', $offset)) {
                     $json['errors'][] = $this->language->get('ms_error_product_invalid_pdf_range');
                     break;
                 }
             }
         }
         if (!empty($json['errors'])) {
             return $json;
         }
         $pathinfo = pathinfo(DIR_DOWNLOAD . $this->config->get('msconf_temp_download_path') . $fileName);
         $list = glob(DIR_IMAGE . $this->config->get('msconf_temp_image_path') . $pathinfo['filename'] . '*\\.png');
         //var_dump($list);
         foreach ($list as $pagePreview) {
             //var_dump('unlinking ' . $pagePreview);
             @unlink($pagePreview);
         }
         $name = DIR_DOWNLOAD . $this->config->get('msconf_temp_download_path') . $fileName . "[" . $filePages . "]";
         $im = new imagick($name);
         $pages = $im->getNumberImages();
         $im->setImageFormat("png");
         $im->setImageCompressionQuality(100);
         $pathinfo = pathinfo(DIR_DOWNLOAD . $this->config->get('msconf_temp_download_path') . $fileName);
         $json['token'] = substr($pathinfo['basename'], 0, strrpos($pathinfo['basename'], '.'));
         if ($im->writeImages(DIR_IMAGE . $this->config->get('msconf_temp_image_path') . $pathinfo['filename'] . '.png', false)) {
             $list = glob(DIR_IMAGE . $this->config->get('msconf_temp_image_path') . $pathinfo['filename'] . '*\\.png');
             foreach ($list as $pagePreview) {
                 $pathinfo = pathinfo($pagePreview);
                 $this->session->data['multiseller']['files'][] = $pathinfo['basename'];
                 $thumb = $this->resizeImage($this->config->get('msconf_temp_image_path') . $pathinfo['basename'], $this->config->get('msconf_image_preview_width'), $this->config->get('msconf_image_preview_height'));
                 $json['images'][] = array('name' => $pathinfo['basename'], 'thumb' => $thumb);
             }
             //var_dump($this->session->data['multiseller']['files']);
             return $json;
         }
     }
 }
Ejemplo n.º 12
0
<?php

define("JPEG_FILE", __DIR__ . "/imagick_test.jpg");
define("PNG_FILE", __DIR__ . "/imagick_test.png");
$im = new imagick('magick:rose');
$im->writeImage(JPEG_FILE);
$im->clear();
// This is the problematic case, setImageFormat doesn't really
// affect writeImageFile.
// So in this case we want to write PNG but file should come out
// as JPEG
$fp = fopen(PNG_FILE, "w+");
$im->readImage(JPEG_FILE);
$im->setImageFormat('png');
$im->writeImageFile($fp);
$im->clear();
fclose($fp);
// Output the format
$identify = new Imagick(PNG_FILE);
echo $identify->getImageFormat() . PHP_EOL;
// Lets try again, setting the filename rather than format
// This should cause PNG image to be written
$fp = fopen(PNG_FILE, "w+");
$im->readImage(JPEG_FILE);
$im->setImageFilename('png:');
$im->writeImageFile($fp);
$im->clear();
fclose($fp);
// If all goes according to plan, on second time we should get PNG
$identify = new Imagick(PNG_FILE);
echo $identify->getImageFormat() . PHP_EOL;
Ejemplo n.º 13
0
        } else {
            if (PHP_OS == 'Linux') {
                //Linux平台
                $wbshell1 = "xvfb-run --server-args=\"-screen 0, 1024x768x24\" cutycapt --min-width=460 --url=" . $site_url . " --out=" . $img_name;
                $wbshell2 = "xvfb-run --server-args=\"-screen 0, 1024x768x24\" cutycapt --min-width=1024 --url=" . $site_url . " --out=" . $img_name;
            }
        }
        //根据生成图片的大小调用语句
        $wbshell = $picsize == 1 ? $wbshell1 : $wbshell2;
        //执行截图语句
        system($wbshell);
        //exec($wbshell);
        //注:下面的操作仅是对图片进一步进行调整,可以缩小图片体积等,并方便更多的处理,并非必须。
        $im = new imagick($img_name);
        //if($picsize==1) $im->resizeImage(490,0,Imagick::FILTER_LANCZOS,1);
        $im->setImageFormat("png");
        $im->setCompressionQuality(90);
        $img_name2 = 'html2png/' . time() . '.png';
        $im->writeImage($img_name2);
        $im->clear();
        $im->destroy();
        //输出图片连接
        $url_this = dirname('http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]) . '/' . $img_name2;
    } else {
        $url_this = dirname('http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]) . '/google.png';
    }
    ?>
<div class="wrapper" >
<h1>内容生成工具</h1>
<ul>
    <li><?php 
Ejemplo n.º 14
0
<?php

phpinfo();
exit;
$pdf = './manual.pdf';
$fp_pdf = fopen($pdf, 'rb');
$img = new imagick();
// [0] can be used to set page number
$img->setResolution(300, 300);
$img->readImageFile($fp_pdf);
$img->setImageFormat("jpg");
$img->setImageCompression(imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality(90);
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$data = $img->getImageBlob();
Ejemplo n.º 15
0
 /**
  * Create thumnbnail and return it's URL on success
  *
  * @param  string $path file path
  * @param $stat
  * @return false|string
  * @internal param string $mime file mime type
  * @author Dmitry (dio) Levashov
  */
 protected function createTmb($path, $stat)
 {
     if (!$stat || !$this->canCreateTmb($path, $stat)) {
         return false;
     }
     $name = $this->tmbname($stat);
     $tmb = $this->tmbPath . DIRECTORY_SEPARATOR . $name;
     // copy image into tmbPath so some drivers does not store files on local fs
     if (($src = $this->fopenCE($path, 'rb')) == false) {
         return false;
     }
     if (($trg = fopen($tmb, 'wb')) == false) {
         $this->fcloseCE($src, $path);
         return false;
     }
     while (!feof($src)) {
         fwrite($trg, fread($src, 8192));
     }
     $this->fcloseCE($src, $path);
     fclose($trg);
     $result = false;
     $tmbSize = $this->tmbSize;
     if ($this->imgLib === 'imagick') {
         try {
             $imagickTest = new imagick($tmb);
             $imagickTest->clear();
             $imagickTest = true;
         } catch (Exception $e) {
             $imagickTest = false;
         }
     }
     if ($this->imgLib === 'imagick' && !$imagickTest || ($s = @getimagesize($tmb)) === false) {
         if ($this->imgLib === 'imagick') {
             try {
                 $imagick = new imagick();
                 $imagick->setBackgroundColor(new ImagickPixel($this->options['tmbBgColor']));
                 $imagick->readImage($this->getExtentionByMime($stat['mime'], ':') . $tmb);
                 $imagick->setImageFormat('png');
                 $imagick->writeImage($tmb);
                 $imagick->clear();
                 if (($s = @getimagesize($tmb)) !== false) {
                     $result = true;
                 }
             } catch (Exception $e) {
             }
         }
         if (!$result) {
             unlink($tmb);
             return false;
         }
         $result = false;
     }
     /* If image smaller or equal thumbnail size - just fitting to thumbnail square */
     if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
         $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
     } else {
         if ($this->options['tmbCrop']) {
             $result = $tmb;
             /* Resize and crop if image bigger than thumbnail */
             if (!($s[0] > $tmbSize && $s[1] <= $tmbSize || $s[0] <= $tmbSize && $s[1] > $tmbSize) || $s[0] > $tmbSize && $s[1] > $tmbSize) {
                 $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
             }
             if ($result && ($s = @getimagesize($tmb)) != false) {
                 $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0;
                 $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0;
                 $result = $this->imgCrop($result, $tmbSize, $tmbSize, $x, $y, 'png');
             } else {
                 $result = false;
             }
         } else {
             $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
         }
         if ($result) {
             $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
         }
     }
     if (!$result) {
         unlink($tmb);
         return false;
     }
     return $name;
 }
Ejemplo n.º 16
0
 /**
  * class_make_file::create_img_frompdf()
  * 
  * @param mixed $pdf_org
  * @param mixed $pfadhier
  * @return
  */
 private function create_img_frompdf($pdf_org, $pfadhier)
 {
     setlocale(LC_ALL, "de_DE");
     //Klasse INI
     $im = new imagick();
     //Auflösung
     $im->setResolution(60, 60);
     //Anzahl der Seiten des PDFs
     $pages = $this->getNumPagesInPDF($pfadhier . $pdf_org);
     //Dann alle Seiten durchlaufen und Bilder erzeugen
     for ($i = 0; $i < $pages; $i++) {
         //Maximal 100 Seiten
         if ($i > 100) {
             continue;
         }
         //Seitenzahl festlegen
         $pdf = $pfadhier . $pdf_org . "[" . $i . "]";
         //auslesen
         if (file_exists($pfadhier . $pdf_org)) {
             try {
                 $im->readImage($pdf);
             } catch (Exception $e) {
                 echo 'Exception abgefangen: ', $e->getMessage(), "\n";
             }
             if (empty($e)) {
                 //die ("NIX");
                 $im->setImageColorspace(255);
                 $im->setCompression(Imagick::COMPRESSION_JPEG);
                 $im->setCompressionQuality(60);
                 $im->setImageFormat('jpg');
                 $im->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
                 //Damti testweise ausgeben
                 #header( "Content-Type: image/png" );
                 #echo $im;
                 #exit();
                 $pdf_img = str_replace(".pdf", "", $pdf_org);
                 $pdf_img = str_replace("/files/pdf/", "", $pdf_img);
                 $im->setImageFileName($pfadhier . "files/images/thumbs/" . $pdf_img . "_" . $i . ".jpg");
                 //Pfade saven
                 echo $image_files[] = $pfadhier . "files/images/thumbs/" . $pdf_img . "_" . $i . ".jpg";
                 //Speichern
                 $im->writeImage();
                 ini_set(Display_errors, "1");
             }
             //Noch verkleinern... image_magick macht die Bilder zu groß
             /**
             			$image = new SimpleImage();
             	   		 $image->load($pfadhier."files/images/thumbs/".$pdf_img."_".$i.".jpg");
             $image->resizeToHeight(300);
             $image->save($pfadhier."files/images/thumbs/".$pdf_img."_".$i."x.jpg");
             unlink($pfadhier."files/images/thumbs/".$pdf_img."_".$i.".jpg");
             echo ($pfadhier."files/images/thumbs/".$pdf_img."_".$i."x.jpg");
             */
         }
     }
     return $image_files;
 }
Ejemplo n.º 17
0
 public function text($text, $color, $size, $font = 'FetteSteinschrift')
 {
     $font = BASE . "vendor/captcha/fonts/en/" . $font . ".ttf";
     $draw = new \ImagickDraw();
     $draw->setGravity(\Imagick::GRAVITY_CENTER);
     $draw->setFont($font);
     $draw->setFontSize($size);
     $draw->setFillColor(new \ImagickPixel($color));
     $im = new \imagick();
     $properties = $im->queryFontMetrics($draw, $text);
     $im->newImage(intval($properties['textWidth'] + 5), intval($properties['textHeight'] + 5), new \ImagickPixel('transparent'));
     $im->setImageFormat('png');
     $im->annotateImage($draw, 0, 0, 0, $text);
     return $im;
 }
Ejemplo n.º 18
0
 /**
  * Convert to output format. This method convert from pdf to specified format with optimizing
  * @throw Exception
  * @access public
  * @param string $outputPath - path to file. May content only path or path with filename
  * @param int/string[=ALL] $page - number of document page wich will be converted into image. If specified 'ALL' - will be converted all pages.
  * @param string $format - output format (see self::getFormats())
  * @param array $resolution - array with x&y resolution DPI
  * @param int $depth - bit depth image
  * @return string/bool[false] - return image path of last converted page
  */
 public function convert($outputPath = '', $page = 'ALL', $format = 'png', $resolution = array('x' => 300, 'y' => 300), $depth = 8)
 {
     if (!Imagick::queryFormats(strtoupper($format))) {
         throw new Exception('Unsupported format');
     }
     $startTime = microtime(true);
     $im = new imagick();
     $im->setResolution($resolution['x'], $resolution['y']);
     $format = strtolower($format);
     $im->setFormat($format);
     if ($outputPath) {
         if (is_dir($outputPath)) {
             $outputPath = $outputPath . pathinfo($this->filePathWithoutType, PATHINFO_FILENAME);
         }
         $outputFileName = $outputPath;
     } else {
         $outputFileName = $this->filePathWithoutType;
     }
     if ($page === 'ALL') {
         $im->readImage($this->filePathWithoutType . '.pdf');
         $im->setImageFormat($format);
         $im->setImageAlphaChannel(11);
         // it's a new constant imagick::ALPHACHANNEL_REMOVE
         $im->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
         $im->setOption($format . ':bit-depth', $depth);
         $im->writeImages($outputFileName . "." . $format, false);
         $logString = '[POINT] File "' . $this->filePathWithoutType . '.pdf" converted to "' . $format . '" with ' . $im->getNumberImages() . ' pages (ex: ' . (microtime(true) - $startTime) . 's)';
         $this->setLog($logString);
         //Optimizing
         if ($format == 'png' && $this->optipngChecking()) {
             $startTime = microtime(true);
             for ($page = $i = 0; $i < $im->getNumberImages(); $i++) {
                 $this->execute('optipng -o=5', $outputFileName . "-" . (int) $i . "." . $format);
             }
             $logString = '[POINT] Files "' . $outputFileName . '-x.' . $format . '" optimized (ex: ' . (microtime(true) - $startTime) . 's)';
             $this->setLog($logString);
         }
     } else {
         $im->readImage($this->filePathWithoutType . '.pdf[' . (int) $page . ']');
         $im->setImageFormat($format);
         $im->setImageAlphaChannel(11);
         // it's a new constant imagick::ALPHACHANNEL_REMOVE
         $im->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
         $im->setOption($format . ':color-type', 2);
         $im->setOption($format . ':bit-depth', $depth);
         $im->writeImage($outputFileName . "-" . (int) $page . "." . $format);
         $logString = '[POINT] File "' . $outputFileName . '.pdf" converted to "' . $format . '" one page (ex: ' . (microtime(true) - $startTime) . 's)';
         $this->setLog($logString);
         //Optimizing
         if ($format == 'png' && $this->optipngChecking()) {
             $startTime = microtime(true);
             $this->execute('optipng -o=5', $outputFileName . "-" . (int) $page . "." . $format);
             $logString = '[POINT] File "' . $outputFileName . "-" . (int) $page . "." . $format . '" optimized (ex: ' . (microtime(true) - $startTime) . 's)';
             $this->setLog($logString);
         }
     }
     if (file_exists($outputFileName . "-" . (int) $page . "." . $format)) {
         return $outputFileName . "-" . (int) $page . "." . $format;
     } else {
         return false;
     }
 }
Ejemplo n.º 19
0
function makethumbnail($page, $pdf_file, $thumb_path)
{
    $pdf_file = $pdf_file;
    $thumb_page = $page + 1;
    $img_save_to = $thumb_path . '/thumbnail_' . $thumb_page . '.jpg';
    $img = new imagick($pdf_file . "[" . $page . "]");
    $img->scaleImage(76, 100);
    $img->setImageFormat('jpg');
    $img = $img->flattenImages();
    $img->writeImage($img_save_to);
    chmod($img_save_to, 0777);
}
 /**
  * Create thumnbnail and return it's URL on success
  *
  * @param  string $path file path
  * @param $stat
  * @return false|string
  * @internal param string $mime file mime type
  * @author Dmitry (dio) Levashov
  */
 protected function createTmb($path, $stat)
 {
     if (!$stat || !$this->canCreateTmb($path, $stat)) {
         return false;
     }
     $name = $this->tmbname($stat);
     $tmb = $this->tmbPath . DIRECTORY_SEPARATOR . $name;
     $maxlength = -1;
     $imgConverter = null;
     // check imgConverter
     $mime = strtolower($stat['mime']);
     list($type) = explode('/', $mime);
     if (isset($this->imgConverter[$mime])) {
         $imgConverter = $this->imgConverter[$mime]['func'];
         if (!empty($this->imgConverter[$mime]['maxlen'])) {
             $maxlength = intval($this->imgConverter[$mime]['maxlen']);
         }
     } else {
         if (isset($this->imgConverter[$type])) {
             $imgConverter = $this->imgConverter[$type]['func'];
             if (!empty($this->imgConverter[$type]['maxlen'])) {
                 $maxlength = intval($this->imgConverter[$type]['maxlen']);
             }
         }
     }
     if ($imgConverter && !is_callable($imgConverter)) {
         return false;
     }
     // copy image into tmbPath so some drivers does not store files on local fs
     if (($src = $this->fopenCE($path, 'rb')) == false) {
         return false;
     }
     if (($trg = fopen($tmb, 'wb')) == false) {
         $this->fcloseCE($src, $path);
         return false;
     }
     stream_copy_to_stream($src, $trg, $maxlength);
     $this->fcloseCE($src, $path);
     fclose($trg);
     // call imgConverter
     if ($imgConverter) {
         if (!call_user_func_array($imgConverter, array($tmb, $stat, $this))) {
             file_exists($tmb) && unlink($tmb);
             return false;
         }
     }
     $result = false;
     $tmbSize = $this->tmbSize;
     if ($this->imgLib === 'imagick') {
         try {
             $imagickTest = new imagick($tmb);
             $imagickTest->clear();
             $imagickTest = true;
         } catch (Exception $e) {
             $imagickTest = false;
         }
     }
     if ($this->imgLib === 'imagick' && !$imagickTest || ($s = getimagesize($tmb)) === false) {
         if ($this->imgLib === 'imagick') {
             $bgcolor = $this->options['tmbBgColor'];
             if ($bgcolor === 'transparent') {
                 $bgcolor = 'rgba(255, 255, 255, 0.0)';
             }
             try {
                 $imagick = new imagick();
                 $imagick->setBackgroundColor(new ImagickPixel($bgcolor));
                 $imagick->readImage($this->getExtentionByMime($stat['mime'], ':') . $tmb);
                 $imagick->setImageFormat('png');
                 $imagick->writeImage($tmb);
                 $imagick->clear();
                 if (($s = getimagesize($tmb)) !== false) {
                     $result = true;
                 }
             } catch (Exception $e) {
             }
         }
         if (!$result) {
             file_exists($tmb) && unlink($tmb);
             return false;
         }
         $result = false;
     }
     /* If image smaller or equal thumbnail size - just fitting to thumbnail square */
     if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
         $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
     } else {
         if ($this->options['tmbCrop']) {
             $result = $tmb;
             /* Resize and crop if image bigger than thumbnail */
             if (!($s[0] > $tmbSize && $s[1] <= $tmbSize || $s[0] <= $tmbSize && $s[1] > $tmbSize) || $s[0] > $tmbSize && $s[1] > $tmbSize) {
                 $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
             }
             if ($result && ($s = getimagesize($tmb)) != false) {
                 $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0;
                 $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0;
                 $result = $this->imgCrop($result, $tmbSize, $tmbSize, $x, $y, 'png');
             } else {
                 $result = false;
             }
         } else {
             $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
         }
         if ($result) {
             if ($s = getimagesize($tmb)) {
                 if ($s[0] !== $tmbSize || $s[1] !== $tmbSize) {
                     $result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
                 }
             }
         }
     }
     if (!$result) {
         unlink($tmb);
         return false;
     }
     return $name;
 }
Ejemplo n.º 21
0
    $fname = md5($file_name[1] . date() . rand(0, 100000)) . "." . $file_name[1];
}
move_uploaded_file($_FILES["file"]["tmp_name"], "../upload/" . $fname);
$img = new imagick();
$img->setResolution(600, 600);
$img->readimage("../upload/" . $fname);
$pdfLength = $img->getNumberImages();
$sql = "INSERT INTO `magazine` (`size`, `series`, `issue`, `createtime`, `isnew`, `status`) VALUES (" . $pdfLength . "," . $series . ",0, '" . date("Y-m-d h:i:s") . "', 1, 0)";
mysql_query($sql, $conn);
$id = mysql_insert_id($conn);
if (!file_exists("../../magazine/")) {
    mkdir("../../magazine/");
}
mkdir("../../magazine/" . $id);
mkdir("../../magazine/" . $id . "/small");
$img->setImageFormat('jpeg');
for ($i = 0; $i < $pdfLength; $i++) {
    $img->setIteratorIndex($i);
    $img->scaleImage(1000, 0);
    $fname = md5($file_name[1] . date() . rand(0, 100000)) . ".jpg";
    while (file_exists("../../magazine/" . $id . "/" . $fname)) {
        $fname = md5($file_name[1] . date() . rand(0, 100000)) . ".jpg";
    }
    $sql = "INSERT INTO `pages` (`magazine`, `name`, `position`) VALUES (" . $id . ", '" . $fname . "'," . $i . ")";
    mysql_query($sql, $conn);
    $img->writeImage("../../magazine/" . $id . "/" . $fname);
    $img->scaleImage(200, 0);
    $img->writeImage("../../magazine/" . $id . "/small/" . $fname);
}
$img->clear();
$img->destroy();
Ejemplo n.º 22
0
 /**
  * @param int $dw
  * @param bool $pdfLogo
  * @param int $pdfLogoSize
  */
 public function showImg($dw = 500, $pdfLogo = false, $pdfLogoSize = 128)
 {
     $cachename = $this->fullpath . $dw . $this->pageid . ".png";
     $cacheimg = $this->cachepath . '/' . $this->_nameFilter($cachename);
     if (class_exists('Imagick')) {
         try {
             $im = $this->_dataCacher($cachename);
             if ($im === false) {
                 $this->_logToFile('File not in cache');
                 $im = new imagick($this->fullpath . '[' . $this->pageid . ']');
                 //$im->setSize($dw*2,$dw*2);
                 $im->setImageFormat("png");
                 $im->adaptiveResizeImage($dw, $dw, true);
                 // add a border to the image
                 $color = new ImagickPixel();
                 $color->setColor("rgb(200,200,200)");
                 $im->borderImage($color, 1, 1);
                 // draw the PDF icon on top of the PDF preview
                 if ($pdfLogo) {
                     $pdflogo = new Imagick($this->assetsPath . $this->deficon);
                     $pdflogo->adaptiveResizeImage($pdfLogoSize, $pdfLogoSize);
                     $im->compositeImage($pdflogo, Imagick::COMPOSITE_DEFAULT, 1, 1);
                 }
                 $this->_dataCacher($cachename, $im);
                 $im->writeImage($cacheimg);
             } else {
                 $this->_logToFile('File IS cached');
             }
             header("Content-Type: image/png");
             header("Content-Disposition: attachment; filename=\"" . $cachename . ".png\";");
             $this->getRawFile($cacheimg, false, 'PNG', true);
         } catch (Exception $e) {
             return parent::showImg($dw);
         }
     } else {
         return parent::showImg($dw);
     }
 }
Ejemplo n.º 23
0
 /**
  * Generate pdf, preview pdf from images uploaded by user.
  *
  * @param array $images
  *
  * @return array
  *
  * @author Kuldeep Dangi <*****@*****.**>
  */
 public function getPdfFromImages($images)
 {
     $fileUploadAbsolutePath = Yii::app()->params['FILE_SERVER_IMAGE_PATH'] . self::FILE_UPLOAD_PATH;
     $pdfUploadAbsolutePath = Yii::app()->params['FILE_SERVER_IMAGE_PATH'] . self::FILE_CONVERT_PATH;
     $upload_file = array();
     $html = $previewHtml = '';
     $randomNumber = MD5($this->getRandomNumber());
     $savedFileNames = array('image' => $randomNumber . '.jpg', 'imagepdf' => $randomNumber . '.pdf.pdf', 'pdf' => $randomNumber . '.pdf');
     $imagesCount = count($images);
     $imageCounterCount = 1;
     foreach ($images as $image) {
         if ($imagesCount > 3 && $imageCounterCount < 4) {
             $previewHtml .= '<img src="../' . self::FILE_UPLOAD_PATH . $image . '"/>';
         } elseif ($imagesCount < 4 && $imageCounterCount == $imagesCount) {
             $previewHtml .= '<img src="../' . self::FILE_UPLOAD_PATH . $image . '"/>';
         }
         $html .= '<img src="../' . self::FILE_UPLOAD_PATH . $image . '"/>';
         $imageCounterCount++;
     }
     $mpdf = Yii::app()->ePdf->mpdf();
     $mpdf->debug = true;
     $mpdf->WriteHTML($html);
     $mpdf->Output('../' . self::FILE_CONVERT_PATH . $savedFileNames['pdf'], 'F');
     $mpdf1 = Yii::app()->ePdf->mpdf();
     $mpdf1->debug = true;
     $mpdf1->WriteHTML($previewHtml);
     $mpdf1->Output('../' . self::FILE_PDF_PREVIEW_PATH . $savedFileNames['imagepdf'], 'F');
     $im = new imagick();
     $im->readimage('/home/notesgen/public_html/' . self::FILE_PDF_PREVIEW_PATH . $savedFileNames['imagepdf']);
     $im->setImageCompressionQuality(0);
     $im->setImageFormat('jpeg');
     $im->writeImage('../' . self::FILE_IMAGE_PATH . $savedFileNames['image']);
     $im->setImageCompressionQuality(80);
     $im->writeImage('../' . self::FILE_IMAGE_PATH_APP . $savedFileNames['image']);
     $im->clear();
     $im->destroy();
     return $savedFileNames;
 }
Ejemplo n.º 24
0
 private function resizeCropImg($pFolder, $pImg, $pW, $pH)
 {
     $im = new imagick();
     $im->readImage($pFolder . $pImg);
     $image = new stdClass();
     $image->dimensions = $im->getImageGeometry();
     $image->w = $image->dimensions['width'];
     $image->h = $image->dimensions['height'];
     $image->ratio = $image->w / $image->h;
     if ($image->w / $pW < $image->h / $pH) {
         $h = ceil($pH * $image->w / $pW);
         $y = ($image->h - $pH * $image->w / $pW) / 2;
         $im->cropImage($image->w, $h, 0, $y);
     } else {
         $w = ceil($pW * $image->h / $pH);
         $x = ($image->w - $pW * $image->h / $pH) / 2;
         $im->cropImage($w, $image->h, $x, 0);
     }
     $im->ThumbnailImage($pW, $pH, true);
     if ($img->type === "PNG") {
         $im->setImageCompressionQuality(55);
         $im->setImageFormat('png');
     } elseif ($img->type === "JPG" || $img->type === "JPEG") {
         $im->setCompressionQuality(100);
         $im->setImageFormat("jpg");
     }
     $im->writeImage($this->ad->url->folder . '/assets/' . $pImg);
     $im->destroy();
 }
 function get_texture($uuid, $x = null, $y = null)
 {
     $image = $this->ci->curl->simple_get($this->asset_service . $uuid);
     if ($image == null) {
         return null;
     }
     $im = new imagick();
     $im->readImageBlob($image);
     $im->setImageFormat("jpeg");
     if ($x != null && $y != null) {
         $im->scaleImage(200, 200, true);
     }
     return $im;
 }
Ejemplo n.º 26
0
 function _resizeImagick(&$model, $field, $path, $size, $geometry, $thumbnailPath)
 {
     $srcFile = $path . $model->data[$model->alias][$field];
     $pathInfo = $this->_pathinfo($srcFile);
     $thumbnailType = $this->settings[$model->alias][$field]['thumbnailType'];
     $isMedia = $this->_isMedia($model, $this->runtime[$model->alias][$field]['type']);
     $image = new imagick();
     if ($isMedia) {
         $image->setResolution(300, 300);
         $srcFile = $srcFile . '[0]';
     }
     $image->readImage($srcFile);
     $height = $image->getImageHeight();
     $width = $image->getImageWidth();
     if (preg_match('/^\\[[\\d]+x[\\d]+\\]$/', $geometry)) {
         // resize with banding
         list($destW, $destH) = explode('x', substr($geometry, 1, strlen($geometry) - 2));
         $image->thumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+x[\\d]+$/', $geometry)) {
         // cropped resize (best fit)
         list($destW, $destH) = explode('x', $geometry);
         $image->cropThumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+w$/', $geometry)) {
         // calculate heigh according to aspect ratio
         $image->thumbnailImage((int) $geometry - 1, 0);
     } elseif (preg_match('/^[\\d]+h$/', $geometry)) {
         // calculate width according to aspect ratio
         $image->thumbnailImage(0, (int) $geometry - 1);
     } elseif (preg_match('/^[\\d]+l$/', $geometry)) {
         // calculate shortest side according to aspect ratio
         $destW = 0;
         $destH = 0;
         $destW = $width > $height ? (int) $geometry - 1 : 0;
         $destH = $width > $height ? 0 : (int) $geometry - 1;
         $imagickVersion = phpversion('imagick');
         $image->thumbnailImage($destW, $destH, !($imagickVersion[0] == 3));
     }
     if ($isMedia) {
         $thumbnailType = $this->settings[$model->alias][$field]['mediaThumbnailType'];
     }
     if (!$thumbnailType || !is_string($thumbnailType)) {
         try {
             $thumbnailType = $image->getImageFormat();
         } catch (Exception $e) {
             $thumbnailType = 'png';
         }
     }
     $fileName = str_replace(array('{size}', '{filename}'), array($size, $pathInfo['filename']), $this->settings[$model->alias][$field]['thumbnailName']);
     $destFile = "{$thumbnailPath}{$fileName}.{$thumbnailType}";
     $image->setImageCompressionQuality($this->settings[$model->alias][$field]['thumbnailQuality']);
     $image->setImageFormat($thumbnailType);
     if (!$image->writeImage($destFile)) {
         return false;
     }
     $image->clear();
     $image->destroy();
     return true;
 }
Ejemplo n.º 27
0
/**
 * @param $pdf
 * @param $id
 * @return string
 * @usage Generates thumbnail from PDF file. [ From v4.1.3 ]
 */
function wpdm_pdf_thumbnail($pdf, $id)
{
    $pdfurl = '';
    if (strpos($pdf, "://")) {
        $pdfurl = $pdf;
        $pdf = str_replace(home_url('/'), ABSPATH, $pdf);
    }
    if ($pdf == $pdfurl) {
        return;
    }
    if (file_exists($pdf)) {
        $source = $pdf;
    } else {
        $source = UPLOAD_DIR . $pdf;
    }
    $dest = WPDM_CACHE_DIR . "/pdfthumbs/{$id}.png";
    $durl = WPDM_BASE_URL . "cache/pdfthumbs/{$id}.png";
    $ext = explode(".", $source);
    $ext = end($ext);
    if ($ext != 'pdf') {
        return '';
    }
    if (file_exists($dest)) {
        return $durl;
    }
    $source = $source . '[0]';
    if (!class_exists('Imagick')) {
        return "Imagick is not installed properly";
    }
    try {
        $image = new imagick($source);
        $image->setResolution(800, 800);
        $image->setImageFormat("png");
        $image->writeImage($dest);
    } catch (Exception $e) {
        return '';
    }
    return $durl;
}
Ejemplo n.º 28
0
 function generate_certificate($user = null)
 {
     isset($user) or $user = $this->myUser;
     $elearning_user = elearning_user::get_instance($user->get_name(), elearning_mediathek::get_instance()->get_course()->get_id());
     if ($elearning_user->has_exam_passed()) {
         //generating cert
         $cert = new elearning_certificate();
         $filename_data = $cert->create_certificate($_SESSION["LMS_USER"]->get_login(), $_SESSION["LMS_USER"]->get_forename() . " " . $_SESSION["LMS_USER"]->get_surname(), $elearning_user->get_exam_sum_score(), $elearning_user->get_exam_sum_points(), date("d.m.Y"));
         //save cert to server
         $elearning_user->get_exam_cert()->set_content($filename_data);
         //save pdf to temp
         $login = $_SESSION["LMS_USER"]->get_login();
         $myFile = PATH_TEMP . "zertifikat_{$login}.pdf";
         $fh = fopen($myFile, 'w') or die("can't open file");
         fwrite($fh, $filename_data);
         fclose($fh);
         //chmod($myFile, 0777);
         //create Thumb
         //$command = "/opt/local/bin/convert $filename -geometry 550 -quality 80 jpg:$filename.jpg";
         putenv("MAGICK_TMPDIR=" . PATH_TEMP);
         $im = new imagick($myFile . '[0]');
         /* Convert to jpg */
         $im->setImageFormat("jpg");
         /* Thumbnail the image */
         $im->thumbnailImage(150, null);
         //save Thumb
         $elearning_user->get_exam_cert_preview()->set_content((string) $im);
         // delete file
         unlink($myFile);
     }
 }
Ejemplo n.º 29
0
 public function _resizeImagick(Model $model, $field, $path, $size, $geometry, $thumbnailPath)
 {
     $srcFile = $path . $model->data[$model->alias][$field];
     $pathInfo = $this->_pathinfo($srcFile);
     $thumbnailType = $imageFormat = $this->settings[$model->alias][$field]['thumbnailType'];
     $isMedia = $this->_isMedia($model, $this->runtime[$model->alias][$field]['type']);
     $image = new imagick();
     if ($isMedia) {
         $image->setResolution(300, 300);
         $srcFile = $srcFile . '[0]';
     }
     $image->readImage($srcFile);
     $height = $image->getImageHeight();
     $width = $image->getImageWidth();
     if (preg_match('/^\\[[\\d]+x[\\d]+\\]$/', $geometry)) {
         // resize with banding
         list($destW, $destH) = explode('x', substr($geometry, 1, strlen($geometry) - 2));
         $image->thumbnailImage($destW, $destH, true);
         $imageGeometry = $image->getImageGeometry();
         $x = ($imageGeometry['width'] - $destW) / 2;
         $y = ($imageGeometry['height'] - $destH) / 2;
         $image->setGravity(Imagick::GRAVITY_CENTER);
         $image->extentImage($destW, $destH, $x, $y);
     } elseif (preg_match('/^[\\d]+x[\\d]+$/', $geometry)) {
         // cropped resize (best fit)
         list($destW, $destH) = explode('x', $geometry);
         $image->cropThumbnailImage($destW, $destH);
     } elseif (preg_match('/^[\\d]+w$/', $geometry)) {
         // calculate heigh according to aspect ratio
         $image->thumbnailImage((int) $geometry - 1, 0);
     } elseif (preg_match('/^[\\d]+h$/', $geometry)) {
         // calculate width according to aspect ratio
         $image->thumbnailImage(0, (int) $geometry - 1);
     } elseif (preg_match('/^[\\d]+l$/', $geometry)) {
         // calculate shortest side according to aspect ratio
         $destW = 0;
         $destH = 0;
         $destW = $width > $height ? (int) $geometry - 1 : 0;
         $destH = $width > $height ? 0 : (int) $geometry - 1;
         $imagickVersion = phpversion('imagick');
         $image->thumbnailImage($destW, $destH, !($imagickVersion[0] == 3));
     }
     if ($isMedia) {
         $thumbnailType = $imageFormat = $this->settings[$model->alias][$field]['mediaThumbnailType'];
     }
     if (!$thumbnailType || !is_string($thumbnailType)) {
         try {
             $thumbnailType = $imageFormat = $image->getImageFormat();
             // Fix file casing
             while (true) {
                 $ext = false;
                 $pieces = explode('.', $srcFile);
                 if (count($pieces) > 1) {
                     $ext = end($pieces);
                 }
                 if (!$ext || !strlen($ext)) {
                     break;
                 }
                 $low = array('ext' => strtolower($ext), 'thumbnailType' => strtolower($thumbnailType));
                 if ($low['ext'] == 'jpg' && $low['thumbnailType'] == 'jpeg') {
                     $thumbnailType = $ext;
                     break;
                 }
                 if ($low['ext'] == $low['thumbnailType']) {
                     $thumbnailType = $ext;
                 }
                 break;
             }
         } catch (Exception $e) {
             $this->log($e->getMessage(), 'upload');
             $thumbnailType = $imageFormat = 'png';
         }
     }
     $fileName = str_replace(array('{size}', '{filename}', '{primaryKey}'), array($size, $pathInfo['filename'], $model->id), $this->settings[$model->alias][$field]['thumbnailName']);
     $destFile = "{$thumbnailPath}{$fileName}.{$thumbnailType}";
     $image->setImageCompressionQuality($this->settings[$model->alias][$field]['thumbnailQuality']);
     $image->setImageFormat($imageFormat);
     if (!$image->writeImage($destFile)) {
         return false;
     }
     $image->clear();
     $image->destroy();
     return true;
 }
Ejemplo n.º 30
0
//PDF
// https://gist.github.com/smalot/6183152
// pdftotext
$str = "";
if ($file->getType() == "doc") {
    $str = exec("catdoc '" . escapeshellcmd($filename) . "'");
}
if ($file->getType() == "docx") {
    $str = exec("unzip -p '" . escapeshellcmd($filename) . "' word/document.xml | sed -e 's/<\\/w:p>/\n/g; s/<[^>]\\{1,\\}>//g; s/[^[:print:]\n]\\{1,\\}//g'");
}
if ($file->getType() == "pdf") {
    include "pdfparser.php";
    $parser = new PdfParser();
    $str = $parser->parseFile($filename);
    $im = new imagick($filename);
    $im->setImageFormat('jpg');
    $imdata = base64_encode($im);
}
$textarr1 = preg_split("/\\s+/", $str);
$textarr = [];
foreach ($textarr1 as $b) {
    if (!in_array($b, $textarr)) {
        $textarr[$b] = 1;
    } else {
        $textarr[$b] += 1;
    }
}
$a = $file->originalname;
$b = $filename;
$c = $file->filesize;
$d = $conn->real_ecape_string($file->getType());