本文整理汇总了PHP中ilUtil::convertImage方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::convertImage方法的具体用法?PHP ilUtil::convertImage怎么用?PHP ilUtil::convertImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilUtil
的用法示例。
在下文中一共展示了ilUtil::convertImage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateThumbForFile
protected function generateThumbForFile($path, $file)
{
$filename = $path . $file;
if (@file_exists($filename)) {
$thumbpath = $path . $this->getThumbPrefix() . $file;
$path_info = @pathinfo($filename);
$ext = "";
switch (strtoupper($path_info['extension'])) {
case 'PNG':
$ext = 'PNG';
break;
case 'GIF':
$ext = 'GIF';
break;
default:
$ext = 'JPEG';
break;
}
ilUtil::convertImage($filename, $thumbpath, $ext, $this->getThumbSize());
}
}
示例2: generatePreviewPic
/**
* Upload video preview picture
*
* @param
* @return
*/
function generatePreviewPic($a_width, $a_height)
{
$item = $this->getMediaItem("Standard");
if ($item->getLocationType() == "LocalFile" && is_int(strpos($item->getFormat(), "image/"))) {
$dir = ilObjMediaObject::_getDirectory($this->getId());
$file = $dir . "/" . $item->getLocation();
if (is_file($file)) {
if (ilUtil::isConvertVersionAtLeast("6.3.8-3")) {
ilUtil::execConvert($file . "[0] -geometry " . $a_width . "x" . $a_height . "^ -gravity center -extent " . $a_width . "x" . $a_height . " PNG:" . $dir . "/mob_vpreview.png");
} else {
ilUtil::convertImage($file, $dir . "/mob_vpreview.png", "PNG", $a_width . "x" . $a_height);
}
}
}
}
示例3: copyOriginal
/**
* Copy the orginal file
*/
function copyOriginal()
{
global $lng;
$this->createWorkDirectory();
if ($this->getLocationType() != "Reference") {
ilUtil::convertImage($this->getDirectory() . "/" . $this->getLocation(), $this->getMapWorkCopyName(), $this->getMapWorkCopyType());
} else {
// first copy the external file, if necessary
if (!is_file($this->getMapWorkCopyName(true)) || filesize($this->getMapWorkCopyName(true)) == 0) {
$handle = @fopen($this->getLocation(), "r");
$lcopy = fopen($this->getMapWorkCopyName(true), "w");
if ($handle && $lcopy) {
while (!feof($handle)) {
$content = fread($handle, 4096);
fwrite($lcopy, $content);
}
}
@fclose($lcopy);
@fclose($handle);
}
// now, create working copy
ilUtil::convertImage($this->getMapWorkCopyName(true), $this->getMapWorkCopyName(), $this->getMapWorkCopyType());
}
if (!is_file($this->getMapWorkCopyName())) {
ilUtil::sendFailure($lng->txt("cont_map_file_not_generated"));
return false;
}
return true;
}
示例4: importCertificate
/**
* Reads an import ZIP file and creates a certificate of it
*
* @return boolean TRUE if the import succeeds, FALSE otherwise
*/
public function importCertificate($zipfile, $filename)
{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$importpath = $this->createArchiveDirectory();
if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename)) {
ilUtil::delDir($importpath);
return FALSE;
}
ilUtil::unzip($importpath . $filename, TRUE);
$subdir = str_replace(".zip", "", strtolower($filename)) . "/";
$copydir = "";
if (is_dir($importpath . $subdir)) {
$dirinfo = ilUtil::getDir($importpath . $subdir);
$copydir = $importpath . $subdir;
} else {
$dirinfo = ilUtil::getDir($importpath);
$copydir = $importpath;
}
$xmlfiles = 0;
$otherfiles = 0;
foreach ($dirinfo as $file) {
if (strcmp($file["type"], "file") == 0) {
if (strpos($file["entry"], ".xml") !== FALSE) {
$xmlfiles++;
} else {
if (strpos($file["entry"], ".zip") !== FALSE) {
} else {
$otherfiles++;
}
}
}
}
// if one XML file is in the archive, we try to import it
if ($xmlfiles == 1) {
foreach ($dirinfo as $file) {
if (strcmp($file["type"], "file") == 0) {
if (strpos($file["entry"], ".xml") !== FALSE) {
$xsl = file_get_contents($copydir . $file["entry"]);
// as long as we cannot make RPC calls in a given directory, we have
// to add the complete path to every url
$xsl = preg_replace("/url\\([']{0,1}(.*?)[']{0,1}\\)/", "url(" . $this->getAdapter()->getCertificatePath() . "\${1})", $xsl);
$this->saveCertificate($xsl);
} else {
if (strpos($file["entry"], ".zip") !== FALSE) {
} else {
@copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0) {
// upload of the background image, create a preview
ilUtil::convertImage($this->getBackgroundImagePath(), $this->getBackgroundImageThumbPath(), "JPEG", 100);
}
}
}
}
}
} else {
ilUtil::delDir($importpath);
return FALSE;
}
ilUtil::delDir($importpath);
return TRUE;
}
示例5: uploadBackgroundImage
/**
* Uploads a background image for the certificate. Creates a new directory for the
* certificate if needed. Removes an existing certificate image if necessary
*
* @param string $image_tempfilename Name of the temporary uploaded image file
* @return integer An errorcode if the image upload fails, 0 otherwise
*/
public function uploadBackgroundImage($image_tempfilename)
{
if (!empty($image_tempfilename)) {
$image_filename = "background_upload";
$convert_filename = $this->getBackgroundImageName();
$imagepath = $this->getBackgroundImageDefaultFolder();
if (!file_exists($imagepath)) {
ilUtil::makeDirParents($imagepath);
}
// upload the file
if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $this->getBackgroundImageTempfilePath())) {
return FALSE;
}
// convert the uploaded file to JPEG
ilUtil::convertImage($this->getBackgroundImageTempfilePath(), $this->getBackgroundImagePath(), "JPEG");
ilUtil::convertImage($this->getBackgroundImageTempfilePath(), $this->getBackgroundImageThumbPath(), "JPEG", 100);
if (!file_exists($this->getBackgroundImagePath())) {
// something went wrong converting the file. use the original file and hope, that PDF can work with it
if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath())) {
return FALSE;
}
}
unlink($this->getBackgroundImageTempfilePath());
if (file_exists($this->getBackgroundImagePath()) && filesize($this->getBackgroundImagePath()) > 0) {
return TRUE;
}
}
return FALSE;
}
示例6: fromXML
//.........这里部分代码省略.........
$this->object->setElementHeight($item->getMetadataEntry("element_height"));
$this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
$this->object->setShuffle($shuffle);
$points = 0;
$solanswers = array();
foreach ($answers as $answer) {
$solanswers[$answer["solutionorder"]] = $answer;
}
ksort($solanswers);
foreach ($solanswers as $answer) {
$points += $answer["points"];
if ($type == OQ_TERMS || $type == OQ_NESTED_TERMS) {
$this->object->addAnswer($answer["answertext"], -1, $answer['answerdepth']);
} else {
if ($type == OQ_PICTURES || $type == OQ_NESTED_PICTURES) {
$this->object->addAnswer($answer["answerimage"]["label"], -1, $answer['answerdepth']);
}
}
}
$points = $item->getMetadataEntry("points") > 0 ? $item->getMetadataEntry("points") : $points;
$this->object->setPoints($points);
// additional content editing mode information
$this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
$this->object->saveToDb();
if (count($item->suggested_solutions)) {
foreach ($item->suggested_solutions as $suggested_solution) {
$this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
}
$this->object->saveToDb();
}
foreach ($answers as $answer) {
if ($type == OQ_PICTURES || $type == OQ_NESTED_PICTURES) {
include_once "./Services/Utilities/classes/class.ilUtil.php";
$image =& base64_decode($answer["answerimage"]["content"]);
$imagepath = $this->object->getImagePath();
if (!file_exists($imagepath)) {
ilUtil::makeDirParents($imagepath);
}
$imagepath .= $answer["answerimage"]["label"];
$fh = fopen($imagepath, "wb");
if ($fh == false) {
// global $ilErr;
// $ilErr->raiseError($this->object->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
// return;
} else {
$imagefile = fwrite($fh, $image);
fclose($fh);
}
// create thumbnail file
$thumbpath = $imagepath . "." . "thumb.jpg";
ilUtil::convertImage($imagepath, $thumbpath, "JPEG", $this->object->getThumbGeometry());
}
}
foreach ($feedbacksgeneric as $correctness => $material) {
$m = $this->object->QTIMaterialToString($material);
$feedbacksgeneric[$correctness] = $m;
}
$questiontext = $this->object->getQuestion();
$answers =& $this->object->getAnswers();
// handle the import of media objects in XHTML code
if (is_array($_SESSION["import_mob_xhtml"])) {
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
include_once "./Services/RTE/classes/class.ilRTE.php";
foreach ($_SESSION["import_mob_xhtml"] as $mob) {
if ($tst_id > 0) {
$importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
} else {
$importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
}
$GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
$media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
$questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
foreach ($answers as $key => $value) {
$answer_obj =& $answers[$key];
$answer_obj->setAnswertext(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $answer_obj->getAnswertext()));
}
foreach ($feedbacksgeneric as $correctness => $material) {
$feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
}
}
}
$this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
foreach ($answers as $key => $value) {
$answer_obj =& $answers[$key];
$answer_obj->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($answer_obj->getAnswertext(), 1));
}
foreach ($feedbacksgeneric as $correctness => $material) {
$this->object->feedbackOBJ->importGenericFeedback($this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
}
$this->object->saveToDb();
if ($tst_id > 0) {
$q_1_id = $this->object->getId();
$question_id = $this->object->duplicate(true, null, null, null, $tst_id);
$tst_object->questions[$question_counter++] = $question_id;
$import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
} else {
$import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
}
}