当前位置: 首页>>代码示例>>PHP>>正文


PHP imagick::clear方法代码示例

本文整理汇总了PHP中imagick::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::clear方法的具体用法?PHP imagick::clear怎么用?PHP imagick::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imagick的用法示例。


在下文中一共展示了imagick::clear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mkdir

 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;
     }
 }
开发者ID:beafus,项目名称:Living-Meki-Platform,代码行数:33,代码来源:functions.php

示例2: foreach

                // something went wrong, handle the problem
            }
            @unlink($tmpfile);
        }
    }
    // Print the output
    foreach ($image_list as $img) {
        if ($img['thumb'] != '') {
            $url = $img['url'];
            $title = $img['title'];
            $thumb = $img['thumb'];
            $subreddit = $img['subreddit'];
            $permalink = "http://reddit.com/" . $img['permalink'];
            $img = new imagick($thumb);
            $height = $img->getImageHeight();
            $img->clear();
            $img->destroy();
            $thumb = '/' . $thumb;
            $subreddit_text = '';
            if ($bSubreddit) {
                $subreddit_text = '<a class="cat" href="http://redditporn.com/r/' . $subreddit . '" style="color: #3BB9FF">' . $subreddit . '</a><br/>';
            }
            echo '<li id="mosaic1170" class="item_image" style="height: ' . ($height + 4) . 'px;">
				<div class="img">
					<a href="' . $url . '" target="_blank"><img src="' . $thumb . '" alt="' . $title . '" width="300" height="' . $height . '"/></a>
				</div>
				<div class="info">
					' . $subreddit_text . '
					<a href="' . $permalink . '" target="_blank">' . $title . '</a>
				</div>
				</li>';
开发者ID:ReillyKlevre,项目名称:redditporn,代码行数:31,代码来源:index.php

示例3: imagick

<?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;
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:022_writeimagefileformat.php

示例4: resize_imagick

 private function resize_imagick($src, $width, $height, $quality, $preserveExif)
 {
     try {
         $img = new imagick($src);
         if (strtoupper($img->getImageFormat()) === 'JPEG') {
             $img->setImageCompression(imagick::COMPRESSION_JPEG);
             $img->setImageCompressionQuality($quality);
             if (!$preserveExif) {
                 try {
                     $orientation = $img->getImageOrientation();
                 } catch (ImagickException $e) {
                     $orientation = 0;
                 }
                 $img->stripImage();
                 if ($orientation) {
                     $img->setImageOrientation($orientation);
                 }
             }
         }
         $img->resizeImage($width, $height, Imagick::FILTER_LANCZOS, true);
         $result = $img->writeImage($src);
         $img->clear();
         $img->destroy();
         return $result ? true : false;
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:idea-lab,项目名称:Spectrum,代码行数:28,代码来源:plugin.php

示例5: imagick

 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;
 }
开发者ID:ryantology,项目名称:upload,代码行数:58,代码来源:upload.php

示例6: createTmb

 /**
  * 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;
 }
开发者ID:lalusaud,项目名称:mysite,代码行数:91,代码来源:elFinderVolumeDriver.class.php

示例7: _resizeImagick

 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;
 }
开发者ID:ederdsr,项目名称:civisindicadores,代码行数:84,代码来源:UploadBehavior.php

示例8: processPdf

 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();
 }
开发者ID:kuldeepro,项目名称:notesgen,代码行数:29,代码来源:CronController.php

示例9: getPdfFromImages

 /**
  * Generate pdf, preview pdf from images uploaded by user.
  *
  * @param array $images
  *
  * @return array
  *
  * @author Kuldeep Dangi <kuldeep.dangi@yiifrmae.com>
  */
 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;
 }
开发者ID:kuldeepro,项目名称:notesgen,代码行数:47,代码来源:Extensions.php

示例10: createTmb

 /**
  * 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');
//.........这里部分代码省略.........
开发者ID:bigbrush,项目名称:yii2-big,代码行数:101,代码来源:elFinderVolumeDriver.class.php

示例11: uploadfile

 public function uploadfile()
 {
     $folder = isset($_GET['folder']) ? $_GET['folder'] : 'others';
     $targetFolder = "/upload_file/{$folder}";
     $prefix = time();
     $setting = $this->general_model->get_email_from_setting();
     $type = explode(",", $setting[0]['download_type']);
     foreach ($type as $key => $value) {
         $type[$key] = strtolower($value);
     }
     $userid = $_SESSION['user']['user_id'];
     if (!empty($_FILES)) {
         $_FILES["Filedata"]["name"] = str_replace(' ', '', $_FILES["Filedata"]["name"]);
         $_FILES["Filedata"]["tmp_name"] = str_replace(' ', '', $_FILES["Filedata"]["tmp_name"]);
         $uploaddatafile1 = md5($_FILES["Filedata"]["name"]);
         $tempFile = $_FILES["Filedata"]["tmp_name"];
         $targetPath = $_SERVER["DOCUMENT_ROOT"] . $targetFolder;
         $targetFile = rtrim($targetPath, "/") . "/" . $_FILES["Filedata"]["name"];
         $fileTypes = $type;
         //array("zip","rar");
         $fileParts = pathinfo($_FILES["Filedata"]["name"]);
         if (in_array(strtolower($fileParts["extension"]), $fileTypes)) {
             move_uploaded_file($tempFile, $targetFile);
             if (isset($_GET['w'])) {
                 $w = $_GET['w'];
             } else {
                 $w = 100;
             }
             if (isset($_GET['h'])) {
                 $h = $_GET['h'];
             } else {
                 $h = 100;
             }
             $path_upload = "upload_file/{$folder}/" . $_FILES["Filedata"]["name"];
             $root = dirname(dirname(dirname(__FILE__)));
             $file = '/' . $path_upload;
             //a reference to the file in reference to the current working directory.
             // Process for image
             $image_info = @getimagesize(base_url() . $path_upload);
             if (!empty($image_info)) {
                 $image = true;
             } else {
                 $image = false;
             }
             if ($image) {
                 if (!isset($_SESSION['fileuploadname'])) {
                     $_SESSION['fileuploadname'] = $_FILES["Filedata"]["name"];
                     $_SESSION['fileuploadhtml'] = '';
                 } else {
                     if (empty($_SESSION['fileuploadname'])) {
                         $_SESSION['fileuploadname'] = $_FILES["Filedata"]["name"];
                         $_SESSION['fileuploadhtml'] = '';
                     }
                 }
                 $_SESSION['fileuploadhtml'] .= '<img src="' . base_url() . $path_upload . '" style="width:850px;"/>';
                 echo "2";
                 exit;
             }
             include $root . "/mpdf/mpdf.php";
             require_once $root . "/scribd.php";
             $scribd_api_key = "766ydp7ellofhr7x027wl";
             $scribd_secret = "sec-7zrz2fxxa2chak965tbp67npqw";
             $scribd = new Scribd($scribd_api_key, $scribd_secret);
             $doc_type = null;
             $access = "private";
             $rev_id = null;
             $data = $scribd->upload($file, $doc_type, $access, $rev_id);
             if (!empty($data)) {
                 $result = 0;
                 while ($result == 0) {
                     echo $result = $scribd->getDownloadLinks($data['doc_id']);
                 }
                 file_put_contents('/upload_file/files/c' . $uploaddatafile1 . ".pdf", fopen($result["download_link"], 'r'));
                 //file_put_contents( fopen($result["download_link"], 'r'));
                 $mpdf = new mPDF();
                 $mpdf->SetImportUse();
                 $pagecount = $mpdf->SetSourceFile('/upload_file/files/r' . $uploaddatafile1 . ".pdf");
                 $tplId = $mpdf->ImportPage(1);
                 $mpdf->UseTemplate($tplId);
                 $mpdf->SetDisplayMode('fullpage');
                 $mpdf->SetWatermarkText(' ');
                 $mpdf->watermark_font = 'DejaVuSansCondensed';
                 $mpdf->showWatermarkText = true;
                 $md5 = $uploaddatafile1;
                 $mpdf->Output('/upload_file/files/' . $md5 . '.pdf', '');
                 $mpdf->Thumbnail('/upload_file/files/' . $md5 . '.pdf', 1);
                 $mpdf->Output('/upload_file/files/' . $md5 . '.pdf', '');
                 unlink('/upload_file/files/c' . $uploaddatafile1 . ".pdf");
                 $im = new imagick();
                 $im->readimage('/upload_file/files/' . $md5 . '.pdf');
                 //$im->readimage('/upload_file/files/'.$md5.'.pdf');
                 $im->setImageCompressionQuality(0);
                 $im->setImageFormat('jpeg');
                 $im->writeImage('/upload_file/images/r' . $md5 . '.jpg');
                 $this->db->set('id', $userid);
                 $this->db->set('fullpdf', '/upload_file/files/r' . $uploaddatafile1 . '.pdf');
                 $this->db->set('pdf', '/upload_file/files/' . $md5 . '.pdf');
                 $this->db->set('image', '/upload_file/images/r' . $md5 . '.jpg');
                 $this->db->insert('scribe');
                 $im->clear();
//.........这里部分代码省略.........
开发者ID:kuldeepro,项目名称:notesgen,代码行数:101,代码来源:pages.php


注:本文中的imagick::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。