本文整理汇总了PHP中imagick::readimage方法的典型用法代码示例。如果您正苦于以下问题:PHP imagick::readimage方法的具体用法?PHP imagick::readimage怎么用?PHP imagick::readimage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagick
的用法示例。
在下文中一共展示了imagick::readimage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: pigen_generate
function pigen_generate($file)
{
// Generate thumbnail from PDF
$file_basename = str_replace('.', '-', basename($file));
$file_url = str_replace(basename($file), $file_basename . '.jpg', $file);
$opt = get_option('_pigen_verify_imagick');
if ($opt == 'imagick') {
$im = new imagick();
$im->readimage($file . '[0]');
$im->setImageBackgroundColor('white');
$im = $im->flattenImages();
$im->setImageFormat('jpg');
$im->writeImage($file_url);
$im->clear();
$im->destroy();
} else {
exec("convert {$file}[0] -density 72 -quality 90 -background white -flatten {$file_url}");
// converte files to jpg
}
return $file_url;
}
示例3: mysql_insert_id
ignore_user_abort(true);
set_time_limit(0);
// pixel cache max size
IMagick::setResourceLimit(imagick::RESOURCETYPE_MEMORY, 256);
// maximum amount of memory map to allocate for the pixel cache
IMagick::setResourceLimit(imagick::RESOURCETYPE_MAP, 256);
$mid = $_REQUEST['mid'];
mkdir("../upload/");
$fname = md5($file_name[1] . date() . rand(0, 100000)) . ".jpg";
while (file_exists("../../magazine/" . $mid . "/" . $fname)) {
$fname = md5($file_name[1] . date() . rand(0, 100000)) . ".jpg";
}
move_uploaded_file($_FILES["file"]["tmp_name"], "../upload/" . $fname);
$img = new imagick();
$img->setResolution(500, 500);
$img->readimage("../upload/" . $fname);
$img->scaleImage(1000, 0);
$img->writeImage("../../magazine/" . $mid . "/" . $fname);
$img->scaleImage(200, 0);
$img->writeImage("../../magazine/" . $mid . "/small/" . $fname);
include "conn.php";
$sql = "SELECT `magazine`.`size` FROM `magazine` WHERE `magazine`.`id`=" . $mid . "";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_array($result);
$sql = "INSERT INTO `pages` (`magazine`, `name`, `position`) VALUES (" . $mid . ", '" . $fname . "', '" . $row[0] . "');";
mysql_query($sql, $conn);
$sql = "UPDATE `magazine` SET size=size+1 WHERE `magazine`.`id`='" . $mid . "'";
mysql_query($sql, $conn);
echo mysql_insert_id($conn);
mysql_close($conn);
示例4: 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;
}
示例5: thumbnailPDF
/**
* Get a preview thumbnail for a pdf
* @param string $blob
* @param integer $width
* @param integer $height
*
* @return blob
*/
public static function thumbnailPDF($blob, $width, $height)
{
try {
$im = new imagick();
$im->readimageblob($blob);
$im->setiteratorindex(0);
$im->setImageFormat("png");
$im->scaleimage($width, $height);
} catch (ImagickException $e) {
$im = new imagick();
$im->readimage(realpath(__DIR__ . '/media/default_pdf_logo.png'));
$im->scaleimage($width, $height);
}
return $im->getimageblob();
}
示例6: 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();
//.........这里部分代码省略.........