本文整理汇总了PHP中image::resize方法的典型用法代码示例。如果您正苦于以下问题:PHP image::resize方法的具体用法?PHP image::resize怎么用?PHP image::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::resize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize
public function resize($width, $height = NULL)
{
if ($height === NULL) {
$height = $width;
}
return image::resize($this->file->getPath(), $this->file->getPath(), $width, $height);
}
示例2: getimagesize
$mm->uploadfile($_FILES['avatar'], 'temp', $tempname);
$info = getimagesize(BASEDIR . getpath('uploads') . 'temp/' . $tempname);
//Kein Bild => löschen und Ende
if ($info[0] == 0 || $info[1] == 0) {
$mm->deletefile('temp/' . $tempname);
message($apx->lang->get('MSG_MAXDIM'), 'javascript:history.back()');
require 'lib/_end.php';
}
//Bild zu groß => verkleinern
if ($info[0] > $set['user']['avatar_maxdim'] || $info[1] > $set['user']['avatar_maxdim']) {
if ($ext == 'GIF') {
$ext = 'jpg';
}
$newfile = 'avatar_' . $user->info['userid'] . '_' . time() . '.' . strtolower($ext);
list($picture, $picturetype) = $img->getimage('temp/' . $tempname);
$scaled = $img->resize($picture, $set['user']['avatar_maxdim'], $set['user']['avatar_maxdim'], 1, 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$img->saveimage($scaled, $picturetype, 'user/' . $newfile);
imagedestroy($scaled);
} else {
$mm->copyfile('temp/' . $tempname, 'user/' . $newfile);
}
$mm->deletefile('temp/' . $tempname);
$db->query("UPDATE " . PRE . "_user SET avatar='" . addslashes($newfile) . "',avatar_title='" . addslashes($_POST['avatar_title']) . "' WHERE userid='" . $user->info['userid'] . "' LIMIT 1");
if ($user->info['avatar']) {
$mm->deletefile('user/' . $user->info['avatar']);
}
message($apx->lang->get('MSG_OK'), mklink('user.php?action=avatar', 'user,avatar.html'));
}
示例3: explode
/**
* Uploads an author image to the upload/learning_path/images directory
* @param array The image array, coming from the $_FILES superglobal
* @return boolean True on success, false on error
*/
function upload_image($image_array)
{
$image_moved = false;
if (!empty($image_array['name'])) {
$upload_ok = process_uploaded_file($image_array);
$has_attachment = true;
} else {
$image_moved = true;
}
if ($upload_ok) {
if ($has_attachment) {
$courseDir = api_get_course_path() . '/upload/learning_path/images';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$updir = $sys_course_path . $courseDir;
// Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($image_array['name']), $image_array['type']);
if (!filter_extension($new_file_name)) {
//Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
$image_moved = false;
} else {
$file_extension = explode('.', $image_array['name']);
$file_extension = strtolower($file_extension[sizeof($file_extension) - 1]);
$new_file_name = uniqid('') . '.' . $file_extension;
$new_path = $updir . '/' . $new_file_name;
//$result= @move_uploaded_file($image_array['tmp_name'], $new_path);
// resize the image
include_once api_get_path(LIBRARY_PATH) . 'image.lib.php';
$temp = new image($image_array['tmp_name']);
$picture_infos = @getimagesize($image_array['tmp_name']);
// $picture_infos[0]-> width
if ($picture_infos[0] > 104) {
$thumbwidth = 104;
} else {
$thumbwidth = $picture_infos[0];
}
if ($picture_infos[1] > 96) {
$new_height = 96;
} else {
$new_height = $picture_infos[1];
}
//$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
$temp->resize($thumbwidth, $new_height, 0);
$type = $picture_infos[2];
$result = false;
switch ($type) {
case 2:
$result = $temp->send_image('JPG', $new_path);
break;
case 3:
$result = $temp->send_image('PNG', $new_path);
break;
case 1:
$result = $temp->send_image('GIF', $new_path);
break;
}
$temp->resize($thumbwidth, $new_height, 0);
$type = $picture_infos[2];
$result = false;
switch ($type) {
case 2:
$result = $temp->send_image('JPG', $new_path);
break;
case 3:
$result = $temp->send_image('PNG', $new_path);
break;
case 1:
$result = $temp->send_image('GIF', $new_path);
break;
}
// Storing the image filename
if ($result) {
$image_moved = true;
$this->set_preview_image($new_file_name);
return true;
}
}
}
}
return false;
}
示例4: foreach
foreach ($_FILES as $key => $a) {
if (substr($key, 0, 13) == 'image_gallery') {
if ($cfg_type['gallery_icon']['chose']) {
$icon = upload(str_replace('image_', 'icon_', $key), _UPLOAD, time() . '-', $image_exts);
if (!is_array($icon)) {
$oImg = new image(_UPLOAD . $icon);
$oImg->resize($cfg_type['gallery_icon']['w'], $cfg_type['gallery_icon']['h'], _UPLOAD . $icon);
} else {
$error .= $icon['msg'] . '<br />';
}
}
if ($cfg_type['gallery_img']['chose']) {
$img = upload($key, _UPLOAD, time() . '-', $image_exts);
if (!is_array($img)) {
$oImg = new image(_UPLOAD . $img);
$oImg->resize($cfg_type['gallery_img']['w'], $cfg_type['gallery_img']['h'], _UPLOAD . $img);
if ($cfg_type['gallery_thumb']['chose']) {
$oImg->resize($cfg_type['gallery_thumb']['w'], $cfg_type['gallery_thumb']['h'], _UPLOAD . 'thumb/' . $img);
}
} else {
$error .= $img['msg'] . '<br />';
}
}
if (!$error) {
$name = $_POST[str_replace('image_', 'name_', $key)];
if ($img) {
$data = array('name' => $name, 'icon' => $icon, 'image' => $img);
$oGallery->insert($system->module, $request['id'], $data);
}
}
}
示例5: mediamanager
//Anhänge aktualisieren
$attachments = '';
$data = $db->fetch("\n\t\t\t\tSELECT id, file FROM\n\t\t\t\t" . PRE . "_forum_attachments\n\t\t\t");
if (count($data)) {
require BASEDIR . 'lib/class.mediamanager.php';
require BASEDIR . 'lib/class.image.php';
$mm = new mediamanager();
$img = new image();
foreach ($data as $res) {
$ext = strtolower($mm->getext($res['file']));
if (in_array($ext, array('gif', 'jpg', 'jpe', 'jpeg', 'png'))) {
$fileid = substr($res['file'], 0, -1 * (strlen($ext) - 1));
$thumbnailPath = $fileid . '_thumb.' . $ext;
list($picture, $picturetype) = $img->getimage($res['file']);
//////// THUMBNAIL
$thumbnail = $img->resize($picture, 120, 90, true);
$img->saveimage($thumbnail, $picturetype, $thumbnailPath);
//Cleanup
imagedestroy($picture);
imagedestroy($thumbnail);
unset($picture, $thumbnail);
//Update SQL
$db->query("UPDATE " . PRE . "_forum_attachments SET thumbnail='" . addslashes($thumbnailPath) . "' WHERE id='" . $res['id'] . "' LIMIT 1");
}
}
}
//Thread- und Beitragszahlen berichtigen
@set_time_limit(600);
$data = $db->fetch("\n\t\t\t\tSELECT forumid\n\t\t\t\tFROM " . PRE . "_forums\n\t\t\t");
if (count($data)) {
foreach ($data as $res) {
示例6: explode
if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/pjpeg") && $_FILES["file"]["size"] < 2000000) {
$filetmpname = $_FILES["file"]["tmp_name"];
$filename = $_FILES["file"]["name"];
$filename = str_replace('_', '', $filename);
$filename = explode('.', $filename);
$filename = $filename[1];
$id1 = md5($id);
$filename = $id1 . '.' . $filename;
if ($_FILES["file"]["error"] > 0) {
echo '<script language=\'javascript\'>alert(\'未知错误!\'); window.location.href="' . $ly . '";</script>';
} else {
move_uploaded_file($filetmpname, "upload/touxiang/" . $filename);
$txurl = "upload/touxiang/" . $filename;
$img = new image();
//实例化类文件,
$simg = $img->resize('./' . $txurl, 'upload', '200', '200');
copy($simg, $txurl);
unlink($simg);
$row = $DB->select('*', 'touxiang', "WHERE user='{$user}'")->fetchALL();
$row = $row['0'];
if ($row['user'] == "") {
$DB->insert('touxiang', array('user' => $user, 'txurl' => $txurl));
echo '<script language=\'javascript\'>alert(\'头像修改成功!\'); window.location.href="http://' . $ym . '/?act=user&id=' . $id . '";</script>';
}
if ($row['user'] == $id) {
$DB->update('touxiang', array('txurl' => $txurl), "where user='{$user}'");
echo '<script language=\'javascript\'>alert(\'头像修改成功!\'); window.location.href="http://' . $ym . '/?act=user&id=' . $id . '";</script>';
}
}
} else {
echo '<script language=\'javascript\'>alert(\'不是图片文件,或者文件太大,请重新上传!\'); window.location.href="' . $ly . '";</script>';
示例7: padd
function padd()
{
global $set, $db, $apx;
$_REQUEST['id'] = (int) $_REQUEST['id'];
if (!$_REQUEST['id']) {
die('missing ID!');
}
if (!$this->access_pics($_REQUEST['id'], 'videos.padd')) {
die('you have no right to access this video!');
}
if ($_POST['send'] == 1) {
require_once BASEDIR . 'lib/class.image.php';
$img = new image();
$tblinfo = $db->first("SHOW TABLE STATUS LIKE '" . PRE . "_videos_screens'");
$nextid = $tblinfo['Auto_increment'];
//Bilder prüfen
$error = array();
for ($i = 1; $i <= $set['videos']['addpics']; $i++) {
if (!$_FILES['upload' . $i]['tmp_name']) {
continue;
}
$imginfo = getimagesize($_FILES['upload' . $i]['tmp_name']);
if (!in_array($imginfo[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
$error[] = $apx->lang->get('MSG_NOIMAGE', array('NAME' => $_FILES['upload' . $i]['name']));
}
if ($error) {
info(implode('<br />', $error));
return;
}
}
//Bilder abarbeiten
for ($i = 1; $i <= $set['videos']['addpics']; $i++) {
if (!$_FILES['upload' . $i]['tmp_name']) {
continue;
}
$ext = strtolower($this->mm->getext($_FILES['upload' . $i]['name']));
if ($ext == 'gif') {
$ext = 'jpg';
}
$newname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '.' . $ext;
$newfile = 'videos/screens/' . $newname;
$thumbname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '-thumb.' . $ext;
$thumbfile = 'videos/screens/' . $thumbname;
//Erfolgreichen Upload prüfen
if (!$this->mm->uploadfile($_FILES['upload' . $i], 'videos/screens', $newname)) {
continue;
}
//Bild einlesen
list($picture, $picturetype) = $img->getimage($newfile);
//////// THUMBNAIL
$thumbnail = $img->resize($picture, $set['videos']['thumbwidth'], $set['videos']['thumbheight'], $set['videos']['quality_resize'], $set['videos']['thumb_fit']);
$img->saveimage($thumbnail, $picturetype, $thumbfile);
//////// BILD
//Bild skalieren
if ($picture !== false && !$_POST['noresize' . $i] && $set['videos']['picwidth'] && $set['videos']['picheight']) {
$scaled = $img->resize($picture, $set['videos']['picwidth'], $set['videos']['picheight'], $set['videos']['quality_resize'], 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$picture = $scaled;
}
//Wasserzeichen einfügen
if ($picture !== false && $set['videos']['watermark'] && $_POST['watermark' . $i]) {
$watermarked = $img->watermark($picture, $set['videos']['watermark'], $set['videos']['watermark_position'], $set['videos']['watermark_transp']);
if ($watermarked != $picture) {
imagedestroy($picture);
}
$picture = $watermarked;
}
//Bild erstellen
$img->saveimage($picture, $picturetype, $newfile);
//Cleanup
imagedestroy($picture);
imagedestroy($thumbnail);
unset($picture, $thumbnail);
//In DB eintragen
$db->query("INSERT INTO " . PRE . "_videos_screens (videoid, thumbnail, picture) VALUES ('" . $_REQUEST['id'] . "', '" . addslashes($thumbfile) . "', '" . addslashes($newfile) . "')");
logit('VIDEOS_PADD', 'ID #' . $nextid);
++$nextid;
}
printJSRedirect('action.php?action=videos.pshow&id=' . $_REQUEST['id']);
return;
} else {
for ($i = 1; $i <= $set['videos']['addpics']; $i++) {
$_POST['watermark' . $i] = 1;
$_POST['allowcoms' . $i] = 1;
$_POST['allowrating' . $i] = 1;
}
}
//Felder ausgeben
for ($i = 1; $i <= $set['videos']['addpics']; $i++) {
$upload[$i]['CAPTION'] = compatible_hsc($_POST['caption' . $i]);
$upload[$i]['WATERMARK'] = 1;
$upload[$i]['NORESIZE'] = 0;
$upload[$i]['ALLOWCOMS'] = 1;
$upload[$i]['ALLOWRATING'] = 1;
}
$apx->tmpl->assign('ID', $_REQUEST['id']);
$apx->tmpl->assign('UPLOAD', $upload);
$apx->tmpl->assign('SET_WATERMARK', iif($set['videos']['watermark'], 1, 0));
//.........这里部分代码省略.........
示例8: add_edit_template
/**
* Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version August 2008
* @since Dokeos 1.8.6
*/
function add_edit_template()
{
// initiate the object
$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . $_GET['action'] . '&id=' . $_GET['id']);
// settting the form elements: the header
if ($_GET['action'] == 'add') {
$title = get_lang('AddTemplate');
} else {
$title = get_lang('EditTemplate');
}
$form->addElement('header', '', $title);
// settting the form elements: the title of the template
$form->add_textfield('title', get_lang('Title'), false);
// settting the form elements: the content of the template (wysiwyg editor)
$form->addElement('html_editor', 'template_text', get_lang('Text'));
// settting the form elements: the form to upload an image to be used with the template
$form->addElement('file', 'template_image', get_lang('Image'), '');
// settting the form elements: a little bit information about the template image
$form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
// getting all the information of the template when editing a template
if ($_GET['action'] == 'edit') {
// Database table definition
$table_system_template = Database::get_main_table('system_template');
$sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$row = Database::fetch_array($result);
$defaults['template_id'] = $_GET['id'];
$defaults['template_text'] = $row['content'];
$defaults['title'] = $row['title'];
// adding an extra field: a hidden field with the id of the template we are editing
$form->addElement('hidden', 'template_id');
// adding an extrra field: a preview of the image that is currently used
if (!empty($row['image'])) {
$form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>');
} else {
$form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>');
}
// setting the information of the template that we are editing
$form->setDefaults($defaults);
}
// settting the form elements: the submit button
$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
// setting the rules: the required fields
$form->addRule('title', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('template_text', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required');
// if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
if ($form->validate()) {
// exporting the values
$values = $form->exportValues();
// upload the file
if (!empty($_FILES['template_image']['name'])) {
include_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
$upload_ok = process_uploaded_file($_FILES['template_image']);
if ($upload_ok) {
// Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
// upload dir
$upload_dir = api_get_path(SYS_PATH) . 'home/default_platform_document/';
// create dir if not exists
if (!is_dir($upload_dir)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
$res = @mkdir($upload_dir, $perm);
}
// resize image to max default and upload
require_once api_get_path(LIBRARY_PATH) . 'image.lib.php';
$temp = new image($_FILES['template_image']['tmp_name']);
$picture_infos = @getimagesize($_FILES['template_image']['tmp_name']);
$max_width_for_picture = 100;
if ($picture_infos[0] > $max_width_for_picture) {
$thumbwidth = $max_width_for_picture;
if (empty($thumbwidth) or $thumbwidth == 0) {
$thumbwidth = $max_width_for_picture;
}
$new_height = round($thumbwidth / $picture_infos[0] * $picture_infos[1]);
$temp->resize($thumbwidth, $new_height, 0);
}
$type = $picture_infos[2];
switch (!empty($type)) {
case 2:
$temp->send_image('JPG', $upload_dir . $new_file_name);
break;
case 3:
$temp->send_image('PNG', $upload_dir . $new_file_name);
break;
case 1:
$temp->send_image('GIF', $upload_dir . $new_file_name);
break;
}
}
}
// store the information in the database (as insert or as update)
$table_system_template = Database::get_main_table('system_template');
//.........这里部分代码省略.........
示例9: printInvalidToken
function inline_upload()
{
global $set, $db, $apx;
$file = $_FILES['image'];
//Prüfen ob eine Datei hochgeladen wurde, falls ja verschieben
if (!$file['tmp_name']) {
return;
}
if (!is_uploaded_file($file['tmp_name'])) {
return;
}
if (!checkToken()) {
printInvalidToken();
exit;
}
$ext = strtolower($this->mm->getext($file['name']));
if ($ext == 'gif') {
$ext = 'jpg';
}
$tempfile = md5(microtime()) . '.' . $ext;
$this->mm->uploadfile($file, 'inline', $tempfile);
//Nächste ID auslesen
$tblinfo = $db->first("SHOW TABLE STATUS LIKE '" . PRE . "_inlinescreens'");
$now = time();
//Einheitliche Upload-Zeit, auch wenns nicht stimmt
$newname = 'pic' . '-' . $tblinfo['Auto_increment'] . '.' . $ext;
$newfile = 'inline/' . $newname;
$popname = 'pic' . '-' . $tblinfo['Auto_increment'] . '-popup.' . $ext;
$popfile = 'inline/' . $popname;
//Bild einlesen
require_once BASEDIR . 'lib/class.image.php';
$img = new image();
////// NORMALES BILD
list($picture, $picturetype) = $img->getimage('inline/' . $tempfile);
//Skalieren
if ($picture !== false && ($_POST['size_x'] || $_POST['size_y'])) {
$scaled = $img->resize($picture, $_POST['size_x'], $_POST['size_y'], $set['mediamanager']['quality_resize'], 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$picture = $scaled;
}
//Wasserzeichen einfügen
if ($picture !== false && $set['mediamanager']['watermark'] && $_POST['watermark']) {
$watermarked = $img->watermark($picture, $set['mediamanager']['watermark'], $set['mediamanager']['watermark_position'], $set['mediamanager']['watermark_transp']);
if ($watermarked != $picture) {
imagedestroy($picture);
}
$picture = $watermarked;
}
//Bild erstellen
$img->saveimage($picture, $picturetype, $newfile);
imagedestroy($picture);
////// POPUP-BILD
if ($_POST['popup']) {
list($picture, $picturetype) = $img->getimage('inline/' . $tempfile);
//Skalieren
if ($picture !== false && ($_POST['popup_size_x'] || $_POST['popup_size_y'])) {
$scaled = $img->resize($picture, $_POST['popup_size_x'], $_POST['popup_size_y'], $set['mediamanager']['quality_resize'], 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$picture = $scaled;
}
//Wasserzeichen einfügen
if ($picture !== false && $set['mediamanager']['watermark'] && $_POST['popup_watermark']) {
$watermarked = $img->watermark($picture, $set['mediamanager']['watermark'], $set['mediamanager']['watermark_position'], $set['mediamanager']['watermark_transp']);
if ($watermarked != $picture) {
imagedestroy($picture);
}
$picture = $watermarked;
}
//Bild erstellen
$img->saveimage($picture, $picturetype, $popfile);
imagedestroy($picture);
}
//Cachefile löschen
$this->mm->deletefile('inline/' . $tempfile);
$_POST['addtime'] = time();
$_POST['picture'] = $newfile;
if ($_POST['popup']) {
$_POST['popup'] = $popfile;
} else {
$_POST['popup'] = '';
}
$db->dinsert(PRE . '_inlinescreens', 'module,mid,hash,picture,popup,align,text,addtime');
logit('MEDIAMANAGER_INLINE', 'ID #' . $db->insert_id());
printJSRedirect('action.php?action=mediamanager.inline&module=' . $_REQUEST['module'] . '&mid=' . $_REQUEST['mid'] . '&hash=' . $_REQUEST['hash'] . '&fields=' . $_REQUEST['fields']);
exit;
}
示例10: pictures
function pictures()
{
global $set, $db, $apx;
//Notwendig weil 1.7.0 beim Kopieren ein Bild mit ID 0 erzeugt hatte :/
if (isset($_REQUEST['delpic'])) {
$_REQUEST['delpic'] = (int) $_REQUEST['delpic'];
} else {
$_REQUEST['delpic'] = null;
}
//Bilder auslesen
list($pictures, $nextid) = $db->first("SELECT pictures,pictures_nextid FROM " . PRE . "_articles WHERE id='" . $_REQUEST['id'] . "'");
$pictures = unserialize($pictures);
if (!is_array($pictures)) {
$pictures = array();
}
//Bild löschen
if (isset($_REQUEST['delpic']) && isset($pictures[$_REQUEST['delpic']])) {
if ($_POST['delpic']) {
if (!checkToken()) {
printInvalidToken();
} else {
$picinfo = $pictures[$_REQUEST['delpic']];
require BASEDIR . 'lib/class.mediamanager.php';
$mm = new mediamanager();
if ($picinfo['thumbnail'] && file_exists(BASEDIR . getpath('uploads') . $picinfo['thumbnail'])) {
$mm->deletefile($picinfo['thumbnail']);
}
if ($picinfo['picture'] && file_exists(BASEDIR . getpath('uploads') . $picinfo['picture'])) {
$mm->deletefile($picinfo['picture']);
}
unset($pictures[$_REQUEST['delpic']]);
$db->query("UPDATE " . PRE . "_articles SET pictures='" . addslashes(serialize($pictures)) . "' WHERE id='" . $_REQUEST['id'] . "' LIMIT 1");
printJSRedirect('action.php?action=' . $_REQUEST['action'] . '&id=' . $_REQUEST['id'] . '&pubnow=' . $_REQUEST['pubnow'] . '&pageid=pics');
}
} else {
tmessageOverlay('picdel', array('ID' => $_REQUEST['id'], 'DELPIC' => $_REQUEST['delpic']));
}
} elseif ($_POST['send']) {
require BASEDIR . 'lib/class.mediamanager.php';
$mm = new mediamanager();
require_once BASEDIR . 'lib/class.image.php';
$img = new image();
//Bilder abarbeiten
for ($i = 1; $i <= 5; $i++) {
if (!$_FILES['upload' . $i]['tmp_name']) {
continue;
}
$ext = strtolower($mm->getext($_FILES['upload' . $i]['name']));
if ($ext == 'gif') {
$ext = 'jpg';
}
$newname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '.' . $ext;
$newfile = 'articles/gallery/' . $newname;
$thumbname = 'pic' . '-' . $_POST['id'] . '-' . $nextid . '-thumb.' . $ext;
$thumbfile = 'articles/gallery/' . $thumbname;
//Erfolgreichen Upload prüfen
if (!$mm->uploadfile($_FILES['upload' . $i], 'articles/gallery', $newname)) {
continue;
}
//Bild einlesen
list($picture, $picturetype) = $img->getimage($newfile);
//////// THUMBNAIL
$thumbnail = $img->resize($picture, $set['articles']['thumbwidth'], $set['articles']['thumbheight'], $set['articles']['artpic_quality']);
$img->saveimage($thumbnail, $picturetype, $thumbfile);
//////// BILD
//Bild skalieren
if ($picture !== false && !$_POST['noresize' . $i] && $set['articles']['picwidth'] && $set['articles']['picheight']) {
$scaled = $img->resize($picture, $set['articles']['picwidth'], $set['articles']['picheight'], $set['articles']['artpic_quality'], 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$picture = $scaled;
}
//Wasserzeichen einfügen
if ($picture !== false && $set['articles']['watermark'] && $_POST['watermark' . $i]) {
$watermarked = $img->watermark($picture, $set['articles']['watermark'], $set['articles']['watermark_position'], $set['articles']['watermark_transp']);
if ($watermarked != $picture) {
imagedestroy($picture);
}
$picture = $watermarked;
}
//Bild erstellen
$img->saveimage($picture, $picturetype, $newfile);
//Cleanup
imagedestroy($picture);
imagedestroy($thumbnail);
unset($picture, $thumbnail);
$pictures[$nextid] = array('picture' => $newfile, 'thumbnail' => $thumbfile);
++$nextid;
}
//Bilder eintragen
$db->query("UPDATE " . PRE . "_articles SET pictures='" . addslashes(serialize($pictures)) . "',pictures_nextid='" . intval($nextid) . "' WHERE id='" . $_REQUEST['id'] . "' LIMIT 1");
//Artikel beenden
if ($_POST['submit_finish']) {
$this->finish_article();
return;
} else {
printJSRedirect('action.php?action=' . $_REQUEST['action'] . '&id=' . $_REQUEST['id'] . '&pubnow=' . $_REQUEST['pubnow'] . '&pageid=pics');
}
} else {
//.........这里部分代码省略.........
示例11: run_test
/**
* Unit test
* @param string $file
*/
public static function run_test()
{
$img = new image();
$img->load('/tmp/test.jpg');
$img->resize(700);
$img->watermark('/tmp/wm.png');
$img->resize(200);
$img->save('/tmp/success.png');
}
示例12: makeScreenshots
function makeScreenshots($flvFile, $duration, $id)
{
$files = array();
$screenid = 1;
require_once BASEDIR . 'lib/class.image.php';
$img = new image();
//Screenshots machen
for ($i = 1; $i <= 10; $i += 2) {
unset($output);
$newname = 'pic-' . $id . '-' . $screenid . '.jpg';
$newfile = 'videos/screens/' . $newname;
$thumbname = 'pic-' . $id . '-' . $screenid . '-thumb.jpg';
$thumbfile = 'videos/screens/' . $thumbname;
//Screenshot erzeugen
$screenfrom = floor($duration / 11 * $i);
$cmd = $this->ffmpeg . ' -itsoffset -' . $screenfrom . ' -i ' . $flvFile . ' -vframes 1 -f mjpeg -sameq ' . BASEDIR . getpath('uploads') . $newfile . ' 2>&1';
exec($cmd, $output, $returnval);
echo $cmd . "\n" . implode("\n", $output) . "\nreturns " . $returnval . "\n";
echo "\n--------------------------------------------\n\n";
$this->forceLogOut();
//Bild einlesen
list($picture, $picturetype) = $img->getimage($newfile);
//////// THUMBNAIL
$thumbnail = $img->resize($picture, $this->thumbwidth, $this->thumbheight, $this->quality_resize, false);
$img->saveimage($thumbnail, $picturetype, $thumbfile);
//////// BILD
//Bild skalieren
if ($picture !== false && $this->picwidth && $this->picheight) {
$scaled = $img->resize($picture, $this->picwidth, $this->picheight, $this->quality_resize, 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$picture = $scaled;
}
//Wasserzeichen einfügen
if ($picture !== false && $this->watermark) {
$watermarked = $img->watermark($picture, $this->watermark, $this->watermark_position, $this->watermark_transp);
if ($watermarked != $picture) {
imagedestroy($picture);
}
$picture = $watermarked;
}
//Bild erstellen
$img->saveimage($picture, $picturetype, $newfile);
//Cleanup
imagedestroy($picture);
imagedestroy($thumbnail);
unset($picture, $thumbnail);
$files[] = array('thumbnail' => $thumbfile, 'picture' => $newfile);
++$screenid;
}
return $files;
}
示例13: dirname
$dir = dirname(__FILE__);
$fixtures = $dir . '/../fixtures/image';
require $dir . '/../../lib/php/model/image.class.php';
$baseImage = $fixtures . '/FordMustang.jpg';
$waterMark = $fixtures . '/black-opacity.png';
$image = new image($baseImage);
$images = array();
logSection($image->isActive(), 'is valid image', 'info');
if (!$image->isActive()) {
logSection('exit', 'image is invalid, operation can not be finished', 'error');
}
$width = $image->getData('width');
$height = $image->getData('height');
logSection($width . 'x' . $height, 'test getData method', 'info');
logSection('jpeg' == $image->getType(), 'test getType method', 'info');
$image->resize(500, 500, 'height');
$image->save($fixtures . '/FordMustang-500h.jpg');
$images[] = $fixtures . '/FordMustang-500h.jpg';
logSection(file_exists($fixtures . '/FordMustang-500h.jpg'), '->resize(500, 500, height)->save(FordMustang-500h.jpg)');
logSection($image->getData('height') == 500, 'height == 500');
$image->resize(500, 500, 'width');
$image->save($fixtures . '/FordMustang-500w.jpg');
$images[] = $fixtures . '/FordMustang-500w.jpg';
logSection(file_exists($fixtures . '/FordMustang-500w.jpg'), '->resize(500, 500, width)->save(FordMustang-500w.jpg)');
logSection($image->getData('width') == 500, 'width == 500');
$image->resize(500, 500, 'auto');
$image->save($fixtures . '/FordMustang-500a.jpg');
$images[] = $fixtures . '/FordMustang-500a.jpg';
logSection(file_exists($fixtures . '/FordMustang-500w.jpg'), '->resize(500, 500, auto)->save(FordMustang-500a.jpg)');
logSection($image->getData('width') == 500, 'width == 500');
$image->resize(2, 0, 'zoom');
示例14: image
$img = new image();
$tblinfo = $db->first("SHOW TABLE STATUS LIKE '" . PRE . "_user_pictures'");
$now = time();
//Einheitliche Upload-Zeit, auch wenns nicht stimmt
$i = 0;
foreach ($files as $file) {
++$i;
$random = random_string(5);
$newname = 'pic' . '-' . ($tblinfo['Auto_increment'] + $i - 1) . '-' . $random . '.' . $file['ext'];
$newfile = 'user/gallery-' . $galid . '/' . $newname;
$thumbname = 'pic' . '-' . ($tblinfo['Auto_increment'] + $i - 1) . '-thumb-' . $random . '.' . $file['ext'];
$thumbfile = 'user/gallery-' . $galid . '/' . $thumbname;
//Bild einlesen
list($picture, $picturetype) = $img->getimage($file['source']);
//////// THUMBNAIL
$thumbnail = $img->resize($picture, $set['user']['gallery_thumbwidth'], $set['user']['gallery_thumbheight'], $set['user']['gallery_quality_resize'], $set['user']['gallery_thumb_fit']);
$img->saveimage($thumbnail, $picturetype, $thumbfile);
//////// BILD
//Skalieren
if ($picture !== false && !$file['noresize'] && $set['user']['gallery_picwidth'] && $set['user']['gallery_picheight']) {
$scaled = $img->resize($picture, $set['user']['gallery_picwidth'], $set['user']['gallery_picheight'], $set['user']['gallery_quality_resize'], 0);
if ($scaled != $picture) {
imagedestroy($picture);
}
$picture = $scaled;
}
//Bild erstellen
$img->saveimage($picture, $picturetype, $newfile);
//Cleanup
imagedestroy($picture);
imagedestroy($thumbnail);
示例15: image
$img = new image();
$img->createfromfile($target);
if ($img->width() > $img->height()) {
$left = ($img->width() - $img->height()) / 2;
$img->cut($left, 0, $img->height(), $img->height());
} else {
$top = ($img->height() - $img->width()) / 2;
$img->cut(0, $top, $img->width(), $img->width());
}
$img->resize(64, 64, true);
$thumbtarget = getThumbUrl($target);
$img->save($thumbtarget, 90);
$img2 = new image();
$img2->createfromfile($target);
if ($img2->width() > 640 || $img2->height() > 640) {
$img2->resize(540, 540, true);
}
$midsizetarget = getMidsizeUrl($target);
$img2->save($midsizetarget, 90);
$image['url'] = $target;
$image['dateCreated'] = date("Y-m-d H:i:s");
$image['id'] = $waka['maxImageId'];
$image['name'] = basename($_FILES['uploaded']['name']);
$item['images'][count($item['images'])] = $image;
$item['dateImagesTouched'] = date("Y-m-d H:i:s");
}
}
} else {
echo "Sorry, there was a problem uploading your file.";
}
}