當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Imagick::getNumberImages方法代碼示例

本文整理匯總了PHP中Imagick::getNumberImages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::getNumberImages方法的具體用法?PHP Imagick::getNumberImages怎麽用?PHP Imagick::getNumberImages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Imagick的用法示例。


在下文中一共展示了Imagick::getNumberImages方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: multiframe

 /**
  * Returns true if image has many frames
  *
  * @return bool
  */
 protected function multiframe()
 {
     if ($this->image) {
         return $this->image->getNumberImages() > 1;
     }
     return false;
 }
開發者ID:anp135,項目名稱:altocms,代碼行數:12,代碼來源:Imagick.php

示例2: count

 /**
  * {@inheritdoc}
  */
 public function count()
 {
     try {
         return $this->resource->getNumberImages();
     } catch (\ImagickException $e) {
         throw new RuntimeException('Failed to count the number of layers', $e->getCode(), $e);
     }
 }
開發者ID:mm999,項目名稱:EduSoho,代碼行數:11,代碼來源:Layers.php

示例3: it_should_be_able_to_load_metadata

 public function it_should_be_able_to_load_metadata(Filesystem $filesystem, \Imagick $imagick)
 {
     $file = new LocalFile($this->file);
     $imagick->readImage($this->file)->shouldBeCalled();
     $imagick->getNumberImages()->willReturn(0);
     $imagick->identifyImage()->willReturn(['key' => 'value']);
     $imagick->getImageProperties('*SpotColor*')->willReturn([1]);
     $imagick->clear()->shouldBeCalled();
     $this->getMetadataForFile($file, ['extended' => true])->shouldReturn(['key' => 'value', 'hasSpotColors' => true]);
 }
開發者ID:phpro,項目名稱:zf-filesystem,代碼行數:10,代碼來源:IdentifySpec.php

示例4: _render

 protected function _render($type, $quality)
 {
     $type = $this->_save_function($type, $quality);
     $this->im->setImageCompressionQuality($quality);
     $this->type = $type;
     $this->mime = image_type_to_mime_type($type);
     if ($this->im->getNumberImages() > 1 && $type == "gif") {
         return $this->im->getImagesBlob();
     }
     return $this->im->getImageBlob();
 }
開發者ID:navi8602,項目名稱:wa-shop-ppg,代碼行數:11,代碼來源:waImageImagick.class.php

示例5: getPageCount

 private function getPageCount()
 {
     $filetype = $this->fileinfo['filetype'];
     $mime = $this->fileinfo['mime'];
     // PDFs only for now
     if ($filetype == 'pdf' && $mime == 'application/pdf') {
         // http://stackoverflow.com/a/9642701/1064923
         $image = new \Imagick(public_path() . '/' . $this->directory['full'] . $this->fileinfo['filename']);
         $image->pingImage(public_path() . '/' . $this->directory['full'] . $this->fileinfo['filename']);
         return $image->getNumberImages() / 2;
         // I have no idea why this is needed
     }
     return null;
 }
開發者ID:RoryStolzenberg,項目名稱:spacexstats,代碼行數:14,代碼來源:DocumentUpload.php

示例6: step3

 public function step3()
 {
     Funcs::escapePost();
     if ($_FILES['filecover']['type'] == 'application/pdf' && $_FILES['filepages']['type'] == 'application/pdf') {
         foreach ($_FILES as $key => $item) {
             $name = explode('/', $item['tmp_name']);
             $name = $name[count($name) - 1];
             $dirfile = $_SERVER['DOCUMENT_ROOT'] . TEMP_DIR . $name;
             move_uploaded_file($item['tmp_name'], $dirfile);
             chmod($dirfile, 0777);
             $_SESSION['iuser']['upload'][$key]['name'] = $item['name'];
             $_SESSION['iuser']['upload'][$key]['path'] = $dirfile;
             if ($key == 'filepages') {
                 $imagick = new Imagick($dirfile);
                 $countpage = $imagick->getNumberImages();
                 $countpage = $countpage + $countpage % 2;
                 $_SESSION['iuser']['upload']['countpage'] = $countpage;
             }
         }
     }
 }
開發者ID:sov-20-07,項目名稱:billing,代碼行數:21,代碼來源:UploadModel.php

示例7: getImagePageCount

 /**
  * Return the number of image pages available in the image object.
  *
  * @return integer
  */
 public function getImagePageCount()
 {
     return $this->_imagick->getNumberImages();
 }
開發者ID:jubinpatel,項目名稱:horde,代碼行數:9,代碼來源:Imagick.php

示例8: dol_convert_file

/**
 * 	Convert an image file into anoher format.
 *  This need Imagick php extension.
 *
 *  @param	string	$fileinput  Input file name
 *  @param  string	$ext        Format of target file (It is also extension added to file if fileoutput is not provided).
 *  @param	string	$fileoutput	Output filename
 *  @return	int					<0 if KO, >0 if OK
 */
function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '')
{
    global $langs;
    $image = new Imagick();
    $ret = $image->readImage($fileinput);
    if ($ret) {
        $ret = $image->setImageFormat($ext);
        if ($ret) {
            if (empty($fileoutput)) {
                $fileoutput = $fileinput . "." . $ext;
            }
            $count = $image->getNumberImages();
            $ret = $image->writeImages($fileoutput, true);
            if ($ret) {
                return $count;
            } else {
                return -3;
            }
        } else {
            return -2;
        }
    } else {
        return -1;
    }
}
開發者ID:NoisyBoy86,項目名稱:Dolibarr_test,代碼行數:34,代碼來源:files.lib.php

示例9: make

 /**
  * 
  * @param Oops_File $source
  * @param unknown_type $Scene
  * return Oops_File_Temporary
  */
 public function make($source, $scene = null)
 {
     // 1. Collect source stats
     if (!$source instanceof Oops_Image_File) {
         require_once 'Oops/Image/File.php';
         $source = new Oops_Image_File($source);
     }
     // $source object contains image's width, height and orientation
     // 2. Get scene specification
     require_once 'Oops/Image/Preview/Scene.php';
     $sceneObject = Oops_Image_Preview_Scene::getInstance($scene);
     $rotate = $sceneObject->rotate;
     // 3. Now calculate target image dimensions, rotate angle, etc.
     // 3.1. First calculate rotation
     switch ($source->orient) {
         case 8:
             $rotate += 90;
         case 3:
             $rotate += 90;
         case 6:
             $rotate += 90;
             $rotate = $rotate % 360;
     }
     // 3.2. Calculate target image dimensions
     $sourceWidth = $source->width;
     $sourceHeight = $source->height;
     if ($rotate == 90 || $rotate == 270) {
         $tmp = $sourceWidth;
         $sourceWidth = $sourceHeight;
         $sourceHeight = $tmp;
     }
     $resizeCoeffX = $this->_config->width / $sourceWidth;
     $resizeCoeffY = $this->_config->height / $sourceHeight;
     if (!$this->_config->enlarge) {
         if ($resizeCoeffX > 1 || $resizeCoeffX <= 0) {
             $resizeCoeffX = 1;
         }
         if ($resizeCoeffY > 1 || $resizeCoeffY <= 0) {
             $resizeCoeffY = 1;
         }
     }
     if ($this->_config->crop) {
         // Fit side with maximum resized rate and crop larger side
         $resizeCoeff = max($resizeCoeffX, $resizeCoeffY);
     } else {
         $resizeCoeff = min($resizeCoeffX, $resizeCoeffY);
     }
     $resizeWidth = round($resizeCoeff * $sourceWidth);
     $resizeHeight = round($resizeCoeff * $sourceHeight);
     // Now we have instructions for source modifications - rotate it, resize it
     // 3.3 Calculate preview instructions - crop it, fill it, etc
     $previewWidth = $resizeWidth;
     $previewHeight = $resizeHeight;
     $crop = false;
     if ($this->_config->crop) {
         if ($resizeWidth > $this->_config->width) {
             $previewWidth = $this->_config->width;
             $crop = true;
         }
         if ($resizeHeight > $this->_config->height) {
             $previewHeight = $this->_config->height;
             $crop = true;
         }
     }
     $fillColor = null;
     $fill = false;
     if ($this->_config->fill) {
         $previewWidth = $this->_config->width;
         $previewHeight = $this->_config->height;
         if ($resizeWidth < $previewWidth || $resizeHeight < $previewHeight) {
             $fillColor = $this->_config->fill;
             $fill = true;
         }
     }
     $previewPositionX = ($previewWidth - $resizeWidth) / 2;
     $previewPositionY = ($previewHeight - $resizeHeight) / 2;
     /*
      *  Now we have instructions:
      *  	rotate angle
      *  	resize dimensions
      *  	whenever to crop
      *  	whenever to fill and fill color
      *  And result image width and height
      */
     // Read source image to new Imagick object
     $mgkSource = new Imagick();
     $mgkSource->readImage($source->filename);
     $framesCount = $mgkSource->getNumberImages();
     if (strlen($this->_config->maxFrames)) {
         $framesCount = min($framesCount, $this->_config->maxFrames);
     }
     $backGroundPixel = is_null($fillColor) ? new ImagickPixel() : new ImagickPixel($fillColor);
     if ($framesCount > 1) {
         $mgkPreview = $mgkSource->coalesceImages();
//.........這裏部分代碼省略.........
開發者ID:laiello,項目名稱:oops-project,代碼行數:101,代碼來源:Preview.php

示例10: bulk_import

 /**
  * Bulk PDF import
  * 
  * ## OPTIONS
  * 
  * <source-dir>
  * : required, source directory to import PDF files
  * 
  * <jpeg-compression-quality>
  * : optional, jpeg compression quality, default 60
  *
  * <jpeg-resolution>
  * : optional, jpeg resolution, default 300
  *
  * <post-status>
  * : optional, PDF post status, default "draft"
  *
  * <import-pdf-file>
  * : flag, if set then import PDF file to Wordpress media library
  * 
  * ## EXAMPLES
  * 
  *     wp pdf-light-viewer bulk-import --source-dir="/path/to/pdfs"
  *     wp pdf-light-viewer bulk-import --source-dir="/path/to/pdfs" --jpeg-compression-quality=60 --jpeg-resolution=300 --post-status=publish --import-pdf-file
  *
  * @synopsis --source-dir=<source-dir> [--jpeg-compression-quality=<jpeg-compression-quality>] [--jpeg-resolution=<jpeg-resolution>] [--post-status=<post-status>] [--import-pdf-file]
  * @subcommand bulk-import
  */
 public function bulk_import($args, $assoc_args)
 {
     // options
     $source_dir = $assoc_args['source-dir'];
     $jpeg_compression_quality = isset($assoc_args['jpeg-compression-quality']) ? (int) $assoc_args['jpeg-compression-quality'] : 60;
     $jpeg_resolution = isset($assoc_args['jpeg-resolution']) ? (int) $assoc_args['jpeg-resolution'] : 300;
     $post_status = isset($assoc_args['post-status']) ? $assoc_args['post-status'] : 'draft';
     $import_pdf_file = isset($assoc_args['import-pdf-file']);
     // check requirements
     $plugin_title = PdfLightViewer_Plugin::getData('Title');
     $requirements_met = PdfLightViewer_Plugin::requirements(true);
     if (!$requirements_met) {
         $message = $plugin_title . ': ' . __('requirements not met, please check plugin settings page for more information.', PDF_LIGHT_VIEWER_PLUGIN);
         WP_ClI::error($message, true);
     } else {
         WP_CLI::log($plugin_title . ': ' . __("requirements are met, happy using!", PDF_LIGHT_VIEWER_PLUGIN));
     }
     // check dir
     if (!is_readable($source_dir) || !is_dir($source_dir)) {
         WP_CLI::error(__("Source dir doesn't exist or it's not readable", PDF_LIGHT_VIEWER_PLUGIN), true);
     } else {
         WP_CLI::log(sprintf(__("Searching PDF files in %s", PDF_LIGHT_VIEWER_PLUGIN), $source_dir));
     }
     // check PDF files
     $pdf_files = glob($source_dir . '/*.pdf', GLOB_NOSORT);
     if (empty($pdf_files)) {
         WP_CLI::error(__("Source dir doesn't contain PDF files", PDF_LIGHT_VIEWER_PLUGIN), true);
     } else {
         WP_CLI::log(sprintf(__("%d PDF files found", PDF_LIGHT_VIEWER_PLUGIN), count($pdf_files)));
     }
     // start import
     $pdf_files_count = count($pdf_files);
     $all_pdfs_progress = new \cli\progress\Bar(__("Processing PDF files", PDF_LIGHT_VIEWER_PLUGIN), $pdf_files_count);
     foreach ($pdf_files as $pdf_file_path) {
         // get number of pages
         $im = new Imagick();
         $im->readImage($pdf_file_path);
         $pdf_pages_number = $im->getNumberImages();
         foreach ($im as $_img) {
             $geometry = $_img->getImageGeometry();
             $width = $geometry['width'];
             $height = $geometry['height'];
             break;
         }
         $im->destroy();
         unset($im);
         $current_pdf_progress = new \cli\progress\Bar(sprintf(__("Processing PDF file %s", PDF_LIGHT_VIEWER_PLUGIN), $pdf_file_path), $pdf_pages_number);
         // create PDF post
         $post_id = wp_insert_post(['post_type' => PdfLightViewer_PdfController::$type, 'post_status' => $post_status, 'post_name' => sanitize_title(pathinfo($pdf_file_path, PATHINFO_FILENAME)), 'post_title' => pathinfo($pdf_file_path, PATHINFO_FILENAME)]);
         if (is_wp_error($post_id)) {
             WP_CLI::error(sprintf(__("Could not create PDF post: %s", PDF_LIGHT_VIEWER_PLUGIN), $post_id->get_error_message()), false);
         } else {
             // save pdf to media library
             if ($import_pdf_file) {
                 $image_data = file_get_contents($pdf_file_path);
                 $attach_id = PdfLightViewer_Plugin::create_media_from_data(pathinfo($pdf_file_path, PATHINFO_BASENAME), $image_data);
                 update_post_meta($post_id, 'pdf_file_id', $attach_id);
             }
             $pdf_upload_dir = PdfLightViewer_Plugin::createUploadDirectory($post_id);
             $current_page = 1;
             $ratio = $width / $height;
             do_action(PDF_LIGHT_VIEWER_PLUGIN . ':before_import', $post_id, $pdf_file_path);
             update_post_meta($post_id, '_pdf-light-viewer-import-status', PdfLightViewer_PdfController::STATUS_CLI_PROCESSING);
             update_post_meta($post_id, '_pdf-light-viewer-import-progress', 0);
             update_post_meta($post_id, '_pdf-light-viewer-import-current-page', $current_page);
             update_post_meta($post_id, 'pdf-pages-number', $pdf_pages_number);
             update_post_meta($post_id, 'pdf-page-width', $width);
             update_post_meta($post_id, 'pdf-page-height', $height);
             // process pages
             for ($current_page; $current_page <= $pdf_pages_number; $current_page++) {
                 $page_number = sprintf('%1$05d', $current_page);
                 if (!file_exists($pdf_upload_dir . '/page-' . $page_number . '.jpg')) {
//.........這裏部分代碼省略.........
開發者ID:pabalexa,項目名稱:pdf-light-viewer,代碼行數:101,代碼來源:CLIController.php

示例11: loadPdf

 /**
  * Load a PDF for use on the printer
  *
  * @param string $pdfFile The file to load
  * @param string $pageWidth The width, in pixels, of the printer's output. The first page of the PDF will be scaled to approximately fit in this area.
  * @param array $range array indicating the first and last page (starting from 0) to load. If not set, the entire document is loaded.
  * @throws Exception Where Imagick is not loaded, or where a missing file or invalid page number is requested.
  * @return multitype:EscposImage Array of images, retrieved from the PDF file.
  */
 public static function loadPdf($pdfFile, $pageWidth = 550, array $range = null)
 {
     if (!extension_loaded('imagick')) {
         throw new Exception(__FUNCTION__ . " requires imagick extension.");
     }
     /*
      * Load first page at very low density (resolution), to figure out what
      * density to use to achieve $pageWidth
      */
     try {
         $image = new Imagick();
         $testRes = 2;
         // Test resolution
         $image->setresolution($testRes, $testRes);
         $image->readimage($pdfFile . "[0]");
         $geo = $image->getimagegeometry();
         $image->destroy();
         $width = $geo['width'];
         $newRes = $pageWidth / $width * $testRes;
         /* Load actual document (can be very slow!) */
         $rangeStr = "";
         // Set to [0] [0-1] page range if $range is set
         if ($range != null) {
             if (count($range) != 2 || !isset($range[0]) || !is_integer($range[0]) || !isset($range[1]) || !is_integer($range[1]) || $range[0] > $range[1]) {
                 throw new Exception("Invalid range. Must be two numbers in the array: The start and finish page indexes, starting from 0.");
             }
             $rangeStr = "[" . ($range[0] == $range[1] ? $range[0] : implode($range, "-")) . "]";
         }
         $image->setresolution($newRes, $newRes);
         $image->readImage($pdfFile . "{$rangeStr}");
         $pages = $image->getNumberImages();
         /* Convert images to Escpos objects */
         $ret = array();
         for ($i = 0; $i < $pages; $i++) {
             $image->setIteratorIndex($i);
             $ep = new EscposImage();
             $ep->readImageFromImagick($image);
             $ret[] = $ep;
         }
         return $ret;
     } catch (ImagickException $e) {
         // Wrap in normal exception, so that classes which call this do not themselves require imagick as a dependency.
         throw new Exception($e);
     }
 }
開發者ID:brndwgn,項目名稱:escpos-php,代碼行數:54,代碼來源:EscposImage.php

示例12: dol_convert_file

/**
 * 	Convert file to image
 *  @param      file        Input file name
 *  @param      ext         Extension of target file
 */
function dol_convert_file($file,$ext='png')
{
	global $langs;

	$image=new Imagick();
	$ret = $image->readImage($file);
	if ($ret)
	{
		$ret = $image->setImageFormat($ext);
		if ($ret)
		{
			$count = $image->getNumberImages();
			$ret = $image->writeImages( $file . "." . $ext, true );
			if ($ret) return $count;
			else return -3;
		}
		else
		{
			return -2;
		}
	}
	else
	{
		return -1;
	}

	return 1;
}
開發者ID:remyyounes,項目名稱:dolibarr,代碼行數:33,代碼來源:files.lib.php

示例13: buildSourceImageData

 /**
  * Build source image data (special for Image Magick).
  * 
  * @param string $source_image_path Path to source image.
  * @return boolean Return true on success, false on failed. Call to status_msg property to see the details on failure.
  */
 protected function buildSourceImageData($source_image_path)
 {
     if ($this->source_image_data == null) {
         parent::buildSourceImageData($source_image_path);
     }
     if ($this->status == false && $this->status_msg != null) {
         return false;
     }
     $Imagick = new \Imagick(realpath($source_image_path));
     $i = $Imagick->getNumberImages();
     $this->source_image_frames = $i;
     $this->source_image_data = array_merge($this->source_image_data, array('frames' => $i));
     $Imagick->clear();
     unset($i, $Imagick);
     return true;
 }
開發者ID:rundiz,項目名稱:image,代碼行數:22,代碼來源:Imagick.php

示例14: array

         }
     }
 }
 if (isset($img)) {
     $useZga = false;
     if ($fileType == "image/gif") {
         $transparentPixels = array();
         $transparentMask = array('0', '0', '0', '0');
         exec("timeout 5 convert " . $_FILES["imagefile"]["tmp_name"] . "[0-3] -format '%[fx:int(255*p{10,10}.a)]' info:", $transparentPixels);
         if ($transparentPixels == $transparentMask) {
             // top left pixels are transparent => gif is transparent => don't do it again
             unset($sizes[8]);
             unset($files[8]);
         } else {
             $frameRate = $img->getImageDelay();
             $frameCount = $img->getNumberImages();
             if ($frameRate == 0) {
                 $frameRate = 10;
             }
             $metadata = $img->getImageWidth() . "_" . $img->getImageHeight() . "_" . $img->getNumberImages() . "_" . $frameRate;
             $fileNames[8] = "zga_" . $metadata . "_" . $filePrefix . ".jpg";
             $time = microtime(true) - $start;
             $app['monolog']->addDebug("{$time} Calling montage");
             $v = exec(" timeout 15 montage " . $_FILES["imagefile"]["tmp_name"] . " -coalesce -tile x1111 -frame 0 -geometry '+0+0' -quality 80 -colors 256 -background none -bordercolor none /tmp/media/" . $fileNames[8]);
             $time = microtime(true) - $start;
             $app['monolog']->addDebug("{$time} Called montage");
             $useZga = file_exists("/tmp/media/" . $fileNames[8]);
             if ($useZga) {
                 $zgaSize = filesize("/tmp/media/" . $fileNames[8]);
                 $originalGifSize = filesize($_FILES["imagefile"]["tmp_name"]);
                 $useZga = $originalGifSize > $zgaSize;
開發者ID:holtchesley,項目名稱:Zeega-Media-Server,代碼行數:31,代碼來源:app.php

示例15: extractPages

 private function extractPages()
 {
     // Nome base para os ficheiros extraídos
     $basename = $this->basedir . '/' . pathinfo($this->filename)['filename'] . '-PDF-%03d.png';
     $this->logger->info('Basename: ' . $basename);
     $im = new \Imagick();
     //$im->setResolution(300, 300);
     $im->setResolution(150, 150);
     //$im->setResolution(200, 200);
     $im->readImageBlob(file_get_contents($this->filename));
     $this->logger->info('Cargando: ' . $this->filename);
     $num_pages = $im->getNumberImages();
     $this->logger->info('Total enquisas a procesar: ' . $num_pages);
     $pages = array();
     for ($i = 0; $i < $num_pages; $i++) {
         $im->setIteratorIndex($i);
         $im->setImageFormat('png');
         $filename = sprintf($basename, $i);
         $this->logger->info('Gardando...: ' . $filename);
         $im->writeImage($filename);
         $this->logger->info('Imaxe da enquisa ' . $i . '/' . $num_pages . ' gardada en ' . $filename);
         $pages[] = $filename;
     }
     $im->destroy();
     return $pages;
 }
開發者ID:vifito,項目名稱:compromiso-calidade,代碼行數:26,代碼來源:Scanner.php


注:本文中的Imagick::getNumberImages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。