本文整理汇总了PHP中save_image函数的典型用法代码示例。如果您正苦于以下问题:PHP save_image函数的具体用法?PHP save_image怎么用?PHP save_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
global $fb, $app;
$this->user = array();
$this->img = array();
if (adminOrder('app_mode', 'default') == 'on') {
save_image('https://graph.facebook.com/' . $fb->username . '/picture?width=165&height=165', '__photos/__downloaded/' . $fb->username . '.jpg');
$this->user['name'] = $fb->name;
$this->user['username'] = $fb->username;
$this->user['gender'] = $fb->gender;
$this->user['email'] = 'email@yahoo.com';
// Saving email is against facebook policy
$this->user['photo'] = '__photos/__downloaded/' . $fb->username . '.jpg';
$this->img['font'] = '__stylesheet/__fonts/' . $app['fontName'];
$this->img['size'] = $app['fontSize'];
$this->img['final'] = '__photos/__tmp/' . $this->user['username'] . '.jpg';
} else {
$this->user['name'] = 'samundra kc ';
$this->user['username'] = 'samund';
$this->user['gender'] = 'male';
$this->user['email'] = 'samundrak@yahoo.com';
$this->user['photo'] = '__photos/__downloaded/fadkit.jpg';
$this->img['font'] = '__stylesheet/__fonts/' . adminOrder('fontName', 'config');
$this->img['size'] = adminOrder('fontSize', 'config');
$this->img['final'] = '__photos/__tmp/fadkit.jpg';
}
}
示例2: returnPath
function returnPath($path)
{
if (strpos($path, "http://") !== false || strpos($path, "https://") !== false) {
$upload_path = getUploadDirPath(basename($path));
save_image($path, UPLOAD_CAR_IMAGES . $upload_path);
return $upload_path;
}
}
示例3: images
function images($params)
{
global $template_file;
$template_file = '';
$data = array();
//
$data['path'] = implode('/', $params);
$files_path = STATIC_FILES_ROOT . $data['path'] . '/';
if (!is_dir($files_path)) {
mkdir($files_path, 0775, true);
}
//
if (isset($_FILES['file']) && isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name'] != '') {
include 'interfaces/image_magic.php';
move_uploaded_file($_FILES['file']['tmp_name'], $files_path . $_FILES['file']['name']);
$new_name = time() . '.jpg';
$image = load_image($files_path . $_FILES['file']['name']);
save_image($image, $files_path . $new_name, 'jpg');
//
$thumbnail = thumbnail($image, 160);
save_image($thumbnail, $files_path . 'thumb_' . $new_name, 'jpg');
//
unlink($files_path . $_FILES['file']['name']);
imagedestroy($image);
imagedestroy($thumbnail);
}
//
$data['files'] = array();
if ($dh = opendir($files_path)) {
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..' || is_dir($files_path . '/' . $file)) {
} else {
if (substr($file, 0, 6) == 'thumb_') {
$filemtime = filemtime($files_path . '/' . $file);
$type = strtolower(substr($file, strrpos($file, '.') + 1));
$file_size = filesize($files_path . '/' . $file);
$data['files'][] = array('type' => $type, 'file_size' => intval($file_size / 10.24) / 100, 'created_at' => $filemtime, 'thumb' => $file, 'name' => substr($file, 6));
}
}
}
closedir($dh);
}
return $data;
}
示例4: crop_image_square
function crop_image_square($source, $destination, $image_type, $square_size, $image_width, $image_height, $quality)
{
if ($image_width <= 0 || $image_height <= 0) {
return false;
}
//return false if nothing to resize
if ($image_width > $image_height) {
$y_offset = 0;
$x_offset = ($image_width - $image_height) / 2;
$s_size = $image_width - $x_offset * 2;
} else {
$x_offset = 0;
$y_offset = ($image_height - $image_width) / 2;
$s_size = $image_height - $y_offset * 2;
}
$new_canvas = imagecreatetruecolor($square_size, $square_size);
//Create a new true color image
//Copy and resize part of an image with resampling
if (imagecopyresampled($new_canvas, $source, 0, 0, $x_offset, $y_offset, $square_size, $square_size, $s_size, $s_size)) {
save_image($new_canvas, $destination, $image_type, $quality);
}
return true;
}
示例5: parser
//.........这里部分代码省略.........
$submit = $matches[1][0];
if ($id && $continue) {
// т.е страница с капчей
//сохраним $countOfRequest в базу
$query = "UPDATE {$count_tablename} SET count = '{$countOfRequest}' WHERE user_id = '{$user_id}' AND seacher = '{$seacher}'";
$result = mysql_query($query);
if (!$result) {
error_message(mysql_error());
}
//---------------------Говорим что закончили парсинг----------------
// $query = "UPDATE $activity_tablename SET bool = '0' WHERE seacher = '$seacher'";
// $result = mysql_query($query);
//
// if (!$result) {
// error_message(mysql_error());
// }
// //---------------------Говорим что выдана страница скапчей----------
// // в россии нет зимнего времени
// if (!date('I'))
// $winter = 1;
// else
// $winter = 0;
// $todayDate = mktime(date("H") + $winter, date("i"), date("s"), date("m"), date("d"), date("Y"));
// $accessdate = date("Y-m-d H:i:s", $todayDate);
//
// $query = "UPDATE $captcha_tablename SET bool = '1', accessdate = '$accessdate' WHERE seacher = '$seacher'";
// $result = mysql_query($query);
//
// if (!$result) {
// error_message(mysql_error());
// }
//
// echo 0;
save_image($imgSrc, $url, $img_captcha);
$img_captcha = dirname($_SERVER['PHP_SELF']) . '/' . $img_captcha;
$todayU = intval(date("U"));
$htmlCaptcha = "<form action='sendCaptcha.php' method='Get'>\n <img src='{$img_captcha}" . "?date={$todayU}'" . "/>\n <div id='reload' onClick='reloadGoogle(" . '"' . $url_str . '"' . ");'>reload</div><br/>\n <input type = 'text' id = 'captcha' name = 'captcha' value = '' size = '12'/><br/>\n <input type = 'hidden' id = 'action' name = 'action' value = '{$action}'/>\n <input type = 'hidden' id = 'continue' name = 'continue' value = '{$continue}'/>\n <input type = 'hidden' id = 'id' name = 'id' value = '{$id}'/>\n <input type = 'hidden' id = 'user_id' name = 'user_id' value = '{$user_id}'/>\n <input type = 'hidden' id = 'submitG' name = 'submitG' value = '{$submit}'/>\n <input value = 'Отправить' id = 'submit2' type = 'submit' onClick = 'SubmitCaptchaGoogle(" . '"' . $url_str . '"' . ");return false;'/><br/>\n\n </form>";
print_r($htmlCaptcha);
exit;
} else {
echo 'regexp error';
return 0;
}
}
$countOfRequest++;
$countRequest++;
foreach ($matches_nav[1] as $i => $v) {
$href_nav[$page_nav[1][$i]] = "http://www." . $url . $v;
}
foreach ($matches[1] as $v) {
$href[] = $v;
}
//$href - array of URL of site
/* echo "url=".$url."</br>";
echo "str_query=".$str_query."</br>";
echo "url_str=".$url_str."</br></br>"; */
//Поиск сайта
foreach ($href as $i => $value) {
preg_match('/^(www.)?([^\\/]+)/i', $value, $matchesSite);
preg_match('/^(www.)?(.+)/i', $value, $matchesSiteFull);
$i++;
//Пуникод - рускоязычные домены в utf-8
$punycode = $matchesSite[2];
$punycodeFull = $matchesSiteFull[2];
$idn = new idna_convert(array('idn_version' => 2008));
$punycode = stripos($punycode, 'xn--') !== false ? $idn->decode($punycode) : $idn->encode($punycode);
示例6: preg_match_all
preg_match_all('/<form action="([^>"]+?)"[^>]+?>/i', $response, $matches);
//Value of Input.continue
$action = $matches[1][0];
preg_match_all('/<input type="hidden" name="continue" value="([^>]+?)">/i', $response, $matches);
//Value of Input.continue
$continue = urlencode($matches[1][0]);
preg_match_all('/<input type="hidden" name="id" value="([^>]+?)">/i', $response, $matches);
//Value of Input.id
$id = $matches[1][0];
preg_match_all('/<input type="submit" name="submit" value="([^>]+?)" [^>]+?>/i', $response, $matches);
//Value of Input.submit
$submit = $matches[1][0];
// echo $action;
// echo"<br/>";
// echo $endUrl;
// echo"<br/>";
// echo $imgSrc;
$todayU = intval(date("U"));
if ($id && $continue) {
save_image($imgSrc, $url, $img_captcha);
$img_captcha = dirname($_SERVER['PHP_SELF']) . '/' . $img_captcha;
$htmlCaptcha = "<form action='sendCaptcha.php' method='Get'><img src='{$img_captcha}" . "?date={$todayU}'" . "/>\n <div id='reload' onClick='reloadGoogle(" . '"' . $url_str2 . '"' . ");'>reload</div><br/>\n <input type = 'text' id = 'captcha' name = 'captcha' value = '' size = '12'/><br/>\n <input type = 'hidden' id = 'action' name = 'action' value = '{$action}'/>\n <input type = 'hidden' id = 'continue' name = 'continue' value = '{$continue}'/>\n <input type = 'hidden' id = 'id' name = 'id' value = '{$id}'/>\n <input type = 'hidden' id = 'user_id' name = 'user_id' value = '{$user_id}'/>\n <input type = 'hidden' id = 'submitG' name = 'submitG' value = '{$submit}'/>\n <input value = 'Отправить' id = 'submit2' type = 'submit' onClick = 'SubmitCaptchaGoogle(" . '"' . $url_str2 . '"' . ");return false;'/><br/>\n\n </form>";
print_r($htmlCaptcha);
} else {
// print($response);
echo 'Капча отправлена';
}
} else {
// print($response);
echo 'Капча отправлена';
}
示例7: crop_image_square
function crop_image_square($source, $destination, $image_type, $square_size, $image_width, $image_height, $quality)
{
if ($image_width <= 0 || $image_height <= 0) {
return false;
}
if ($image_width > $image_height) {
$y_offset = 0;
$x_offset = ($image_width - $image_height) / 2;
$s_size = $image_width - $x_offset * 2;
} else {
$x_offset = 0;
$y_offset = ($image_height - $image_width) / 2;
$s_size = $image_height - $y_offset * 2;
}
$new_canvas = imagecreatetruecolor($square_size, $square_size);
if (imagecopyresampled($new_canvas, $source, 0, 0, $x_offset, $y_offset, $square_size, $square_size, $s_size, $s_size)) {
return save_image($new_canvas, $destination, $image_type, $quality);
}
return false;
}
示例8: exit
// DB에 파일내용 저장 성공시
if ($mysqli->affected_rows > 0) {
// 9. 업로드 파일을 새로 만든 파일명으로 변경 및 이동
if (move_uploaded_file($_FILES['image']['tmp_name'], $filePath . $fileName)) {
// 10. 성공시 db저장 내용을 적용(커밋)
$mysqli->commit();
} else {
// 실패시 db에 저장했던 내용 취소를 위한 롤백
$mysqli->rollback();
exit("업로드 실패");
}
// if
}
// if
$image_saving_info = array("id" => $insert_id);
$mysqli->close();
return $image_saving_info;
}
$possible_url = array("save_image");
$value = "An error has occurred";
// echo 'request temp title : '.$_FILES['image']['tmp_name'].'<br>';
// echo 'request 11 title : '.$_POST["title"].'<br>';
if (isset($_POST["title"]) && $_FILES['image']['size'] > 0) {
// echo 'temp filename : '.$_FILES['image']['tmp_name'].'<br>';
// echo 'temp filesize : '.$_FILES['image']['size'].'<br>';
$value = save_image();
} else {
$value = "Missing argument";
}
// return JSON array
exit(json_encode($value));
示例9: userimg_expand_to_square
/**
* Expand image to a square
*
* @param object File
* @return boolean
*/
function userimg_expand_to_square(&$File)
{
if (!$File->is_image()) {
// This must be an image:
return false;
}
$Filetype =& $File->get_Filetype();
if (!$Filetype) {
// File type must be, otherwise we cannot work with this file:
return false;
}
// Get image size:
$image_size = $File->get_image_size('widthheight_assoc');
if ($image_size['width'] == $image_size['height']) {
// We should not expand this image because it is already a square:
return false;
}
load_funcs('files/model/_image.funcs.php');
// Load image:
list($err, $src_imh) = load_image($File->get_full_path(), $Filetype->mimetype);
if (!empty($err)) {
// Error on image loading:
return false;
}
// Expand image to square ---- START:
// Use max side as square size for width & height:
$expanded_image_size = max($image_size);
if ($image_size['width'] > $image_size['height']) {
// If width is more than height then we should center image vertically:
$dst_x = 0;
$dst_y = ceil(($expanded_image_size - $image_size['height']) / 2);
} else {
// If width is less than height then we should center image horizonatally:
$dst_x = ceil(($expanded_image_size - $image_size['width']) / 2);
$dst_y = 0;
}
// Create canvas for new image with white background:
$dst_imh = imagecreatetruecolor($expanded_image_size, $expanded_image_size);
$white_color = imagecolorallocate($dst_imh, 255, 255, 255);
imagefill($dst_imh, 0, 0, $white_color);
if (!@imagecopyresampled($dst_imh, $src_imh, $dst_x, $dst_y, 0, 0, $image_size['width'], $image_size['height'], $image_size['width'], $image_size['height'])) {
// If func imagecopyresampled is not defined for example:
return false;
}
// Expand image to square ---- END.
// Save image:
save_image($dst_imh, $File->get_full_path(), $Filetype->mimetype);
// Remove the old thumbnails:
$File->rm_cache();
return true;
}
示例10: merge_watermark
/**
* @param $file (string) - путь к большой картинке
* @param $watermark (string) - путь к водяному знаку
* @param $coords (array) - массив координат
* @param $opacity (double) - значение прозрачности
* @param $dist (string) - путь к сгенерированной картинке
* @param $flag (string) - флаг - одна картинка накладывается или растрируется
*
*
*/
function merge_watermark($file, $watermark, $coords, $opacity, $dist, $flag)
{
$data = array();
if (!file_exists($file) || !file_exists($watermark)) {
$data['status'] = "NO";
$data['message'] = "Большая картинка или водяной знак не загружены";
$data['url'] = '';
} else {
// Проверяем, есть ли такая папка
if (!file_exists($dist)) {
mkdir($dist, 777);
}
// считываем сигнатуру изображения
$file_sign = exif_imagetype($file);
$watermark_sing = exif_imagetype($watermark);
// Если были переданы не верные картинки
if (!$file_sign || !$watermark_sing) {
$data['status'] = "NO";
$data['message'] = "Были загружены некорректные изображения";
$data['url'] = '';
} else {
// Объекты
$file_img_object = create_image_object($file_sign, $file);
$watermark_img_object = create_image_object($watermark_sing, $watermark);
// если не удалось создать один из объектов
if (!$file_img_object['object'] || !$watermark_img_object['object']) {
$data['status'] = "NO";
$data['message'] = "Возникла ошибка при генерации изображения";
$data['url'] = '';
} else {
// уменьшаем изображение
$file_img_object['object'] = resize_img($file, $file_img_object, 648, 536);
// упрощаем массив координат
$simple_coords = simpled_coords($coords, $flag);
// не верно переданны координаты
if (!$simple_coords) {
$data['status'] = "NO";
$data['message'] = "Не верное переданны координаты";
$data['url'] = '';
} else {
// накладываем изображения по координатам
foreach ($simple_coords as $item_coord) {
imagecopymerge($file_img_object['object'], $watermark_img_object['object'], $item_coord['left'], $item_coord['top'], 0, 0, $watermark_img_object['size']['width'], $watermark_img_object['size']['height'], $opacity);
}
// получаем результат
$result = save_image($file_img_object, $dist);
// Если не получилось сгенерировать изображение
if (!$result['flag']) {
$data['status'] = "NO";
$data['message'] = "Ошибка сохранения изображения";
$data['url'] = '';
} else {
$data['status'] = "OK";
$data['message'] = "Изображение успешно сгенерированно";
$data['url'] = $result['src'];
}
}
}
}
}
echo json_encode($data);
exit;
}
示例11: floor
$_SESSION['firephp']->log('longer than 60 minutes');
$these_hours = floor($_POST['media_item_length_minutes_input'] / 60);
$these_minutes = $_POST['media_item_length_minutes_input'] - $these_hours * 60;
} else {
$these_minutes = $_POST['media_item_length_minutes_input'];
}
//in case there were any hours input
$these_hours += $_POST['media_item_length_hours_input'];
$query .= "\n\t\t\t,'{$these_hours}:{$these_minutes}:00'\n\t \t\t";
$_SESSION['firephp']->log("'{$these_hours}:{$these_minutes}:00'");
} else {
$query .= ",null";
}
if (preg_match('@^http://.*@', $_POST['media_item_image_location_input'])) {
//TODO:watch for images like this [http://imagelocation/something.php?image.jpg&h=200&w=100]
$filename = save_image($_POST['media_item_image_location_input'], 'images/media_items/');
if (!$filename) {
$_SESSION['firephp']->error("there was a problem saving {$_POST['media_item_image_location_input']}");
} else {
$query .= ",'{$filename}'";
}
} else {
$query .= ",'{$_POST['media_item_image_location_input']}'";
}
$query .= "\n\t \t\t,'{$_POST['media_item_rating_input']}'\n\t \t\t,'{$_POST['media_item_notes_input']}'\n\t \t\t,'{$_POST['media_item_medium_input']}'\n\t \t\t,'{$_POST['media_item_barcode_input']}'\n\t \t\t,'{$_POST['media_item_isbn_input']}'\n\t \t\t,'{$_POST['storage_slot_id_input']}'\n\t \t)\n\t \t";
//insert record
mysql_query($query) or $_SESSION['firephp']->error(mysql_error());
$query = "select media_items.id from media_items where media_items.id = LAST_INSERT_ID()";
$query_result = mysql_query($query) or $_SESSION['firephp']->error(mysql_error());
$result_array = mysql2array($query_result);
$media_id = $result_array[0]['id'];
示例12: save_image
<?php
// echo '<pre>';
// var_dump($_FILES);
if (isset($_FILES['image']) && $_FILES['image']['error'] == '') {
$tmp_name = save_image($_FILES['image']);
insert_path_image($tmp_name);
}
$content_template_name = 'add_picture.php';
include 'view/base.php';
示例13: capture
function capture()
{
if (date("H") > 18 && date("H") < 00) {
//is between 6pm and 8am dont capture images
return;
}
echo 'starting</br>';
$imgdata = get_image();
if ($imgdata) {
$saved = save_image($imgdata);
if ($saved) {
echo 'saved </br>';
}
} else {
echo 'image not saved </br>';
}
$cameraposition = get_position();
echo $cameraposition;
next_position($cameraposition);
move_cam($cameraposition);
}
示例14: exif_orientation
/**
* Rotate the JPEG image if EXIF Orientation tag is defined
*
* @param string File name (with full path)
* @param resource Image resource ( result of the function imagecreatefromjpeg() ) (by reference)
* @param boolean TRUE - to save the rotated image in the end of this function
*/
function exif_orientation($file_name, &$imh, $save_image = false)
{
global $Settings;
if (!$Settings->get('exif_orientation')) {
// Autorotate is disabled
return;
}
if (!function_exists('exif_read_data')) {
// EXIF extension is not loaded
return;
}
$EXIF = exif_read_data($file_name);
if (!(isset($EXIF['Orientation']) && in_array($EXIF['Orientation'], array(3, 6, 8)))) {
// EXIF Orientation tag is not defined OR we don't interested in current value
return;
}
load_funcs('files/model/_image.funcs.php');
if (is_null($imh)) {
// Create image resource from file name
$imh = imagecreatefromjpeg($file_name);
}
if (!$imh) {
// Image resource is incorrect
return;
}
switch ($EXIF['Orientation']) {
case 3:
// Rotate for 180 degrees
$imh = @imagerotate($imh, 180, 0);
break;
case 6:
// Rotate for 90 degrees to the right
$imh = @imagerotate($imh, 270, 0);
break;
case 8:
// Rotate for 90 degrees to the left
$imh = @imagerotate($imh, 90, 0);
break;
}
if (!$imh) {
// Image resource is incorrect
return;
}
if ($save_image) {
// Save rotated image
save_image($imh, $file_name, 'image/jpeg');
}
}
示例15: scale_image
function scale_image($source, $destination, $type, $width, $height, $quality, $method)
{
global $twidth;
global $theight;
global $fwidth;
global $fheight;
if ($method === 'thumb') {
$max_width = 240;
$max_height = 240;
} else {
$max_width = 1200;
$max_height = 800;
}
$scale = min($max_width / $width, $max_height / $height);
$new_width = ceil($scale * $width);
$new_height = ceil($scale * $height);
if ($method === 'thumb') {
$twidth = $new_width;
$theight = $new_height;
} else {
$fwidth = $new_width;
$fheight = $new_height;
}
$new_canvas = imagecreatetruecolor($new_width, $new_height);
if (imagecopyresampled($new_canvas, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height)) {
save_image($new_canvas, $destination, $type, $quality);
}
return true;
}