当前位置: 首页>>代码示例>>PHP>>正文


PHP resize_img函数代码示例

本文整理汇总了PHP中resize_img函数的典型用法代码示例。如果您正苦于以下问题:PHP resize_img函数的具体用法?PHP resize_img怎么用?PHP resize_img使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了resize_img函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_query

function process_query()
{
    $upload_dir = '../img/';
    $upload_url_dir = '/img/';
    $upload_file = false;
    try {
        $new_name = rand(0, PHP_INT_MAX) . '.jpg';
        $upload_file = $upload_dir . basename($_FILES['image']['name']);
        move_uploaded_file($_FILES['image']['tmp_name'], $upload_file);
        if (!resize_img($upload_file, $upload_dir . $new_name)) {
            throw new Exception();
        } else {
            $data = $upload_url_dir . $new_name;
            $label = 'url';
            $status = RESPONSE_STATUS_OK;
        }
    } catch (Exception $e) {
        $data = 'file is not image of .jpg .gif .png formats';
        $label = 'error';
        $status = RESPONSE_STATUS_FAIL;
    } finally {
        if ($upload_file) {
            unlink($upload_file);
        }
    }
    api_echo_as_json($data, $label, $status);
}
开发者ID:plFlok,项目名称:vk_test_task,代码行数:27,代码来源:load_image.php

示例2: createImage

 function createImage($imgSrc, $imgDest, $width, $height, $crop = true, $quality = 100)
 {
     if (JFile::exists($imgDest)) {
         $info = getimagesize($imgDest, $imageinfo);
         if ($info[0] == $width && $info[1] == $height) {
             return;
         }
     }
     if (JFile::exists($imgSrc)) {
         $info = getimagesize($imgSrc, $imageinfo);
         $sWidth = $info[0];
         $sHeight = $info[1];
         resize_img($imgSrc, $imgDest, $width, $height, $crop, $quality);
     }
 }
开发者ID:pupsikus,项目名称:sto-city.test,代码行数:15,代码来源:images.php

示例3: mkdir

                        if (!file_exists($dir . '/slideshow') || !is_dir($dir)) {
                            mkdir($dir . '/slideshow');
                        }
                        if (!file_exists($dir . '/thumbnail') || !is_dir($dir)) {
                            mkdir($dir . '/thumbnail');
                        }
                        if (!file_exists($dir . '/manager') || !is_dir($dir)) {
                            mkdir($dir . '/manager');
                        }
                        // for not replace files
                        $i = '';
                        while (file_exists($dir . "/original/{$filename}{$i}.{$ext}")) {
                            $i++;
                        }
                        $filename = "{$filename}{$i}.{$ext}";
                        if (!$file->save("{$dir}/original/{$filename}")) {
                            $response['message'] = "Can't save file here: {$dir}/original/{$filename}";
                        } else {
                            $imagesize = getimagesize("{$dir}/original/{$filename}", $imageinfo);
                            $mime = $imagesize['mime'];
                            resize_img($dir . "/original/{$filename}", $dir . "/manager/{$filename}", 128, 96);
                            $response['success'] = true;
                            $response['file'] = strtolower($filename);
                        }
                    }
                }
            }
        }
    }
}
echo json_encode($response);
开发者ID:pupsikus,项目名称:sto-city.test,代码行数:31,代码来源:uploader.php

示例4: wc_slideshow


//.........这里部分代码省略.........
        case 'slicedown':
            $effect = "sliceDown";
            break;
        case 'sliceup':
            $effect = "sliceUp";
            break;
        case 'sliceupdown':
            $effect = "sliceUpDown";
            break;
        case 'fold':
            $effect = "fold";
            break;
        case 'fade':
            $effect = "fade";
            break;
        case 'boxrain':
            $effect = "boxRain";
            break;
        default:
            $effect = "boxRandom";
    }
    // Trim all space off $content.
    $content = trim($content);
    if ($content > "") {
        $doc = new DOMDocument();
        $doc->loadHTML($content);
        $imageTags = $doc->getElementsByTagName('img');
        //$imageHref = $doc->getElementsByTagName('a');
        foreach ($imageTags as $tag) {
            // $content .= $tag->getAttribute('src') ."\n";
            $IMG_TAGS .= $tag->getAttribute('src') . "\n";
        }
    }
    // Remove all IMG TAGS
    $content = preg_replace("/<img[^>]+\\>/i", "", $content);
    // Remove all HREF TAGS
    $content = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $content);
    // ADD Everything together.
    $content = $content . "\n" . $IMG_TAGS;
    // Organize each line of content into an array.
    $images = !empty($content) ? preg_split("/(\r?\n)/", $content) : '';
    //print_r($images);
    // Check if something exists and that it is an array.
    if (!empty($images) && is_array($images)) {
        // Clear the $content string.
        $content = '';
        // For each image in the array, check for URL's and create the Nivo Slider Content.
        foreach ($images as $image) {
            // Strip any HTML Tags
            $image = trim(strip_tags($image));
            // Separate the image path and link url (looks for comma to distinguish).
            $pos = strpos($image, ',');
            // Look for , and if it exists then we have to split URL and Image path.
            if ($pos === false) {
                $imagePath = $image;
                $imageLink = '';
            } else {
                list($imagePath, $imageLink) = split(',', $image);
            }
            // Clean up any leading or trailing spaces. Make sure to remove http:// and https://
            $imageLink = trim($imageLink);
            $imageLink = remove_http($imageLink);
            // If image path is no empty and it's great than nothing, continue...
            if (!empty($imagePath) && $imagePath > '') {
                // We now use get_attachment_id_from_src() to find the postID of the image attachement (custom function under /functions/common.php).
                $postid = get_attachment_id_from_src($imagePath);
                // Get the image size.
                $image_attributes = wp_get_attachment_image_src($postid, 'full');
                // returns an array
                // Return the post object and title
                $postid = get_post($postid);
                if ($showtitle) {
                    $title = $postid->post_title;
                }
                // Clear tmp vars.
                $imageLinkOpen = "";
                $imageLinkClose = "";
                // Build the tmp vars for the image link (if one was supplied)
                if ($imageLink > "") {
                    $imageLinkOpen = "<a href='http://" . $imageLink . "'>";
                    $imageLinkClose = "</a>";
                }
                // TIMTHUMB OPTION
                if ($use_timthumb) {
                    // Build and add on to the $content string.
                    $content .= $imageLinkOpen . "<img src='" . resize_img($image_attributes[0], $slider_width, $slider_height) . "' width='" . $slider_width . "' " . $slider_height_att . " alt='" . $title . "' title='" . $title . "' data-transition='" . $effect . "' />" . $imageLinkClose;
                } else {
                    // DEFAULT RESIZING OPTION
                    $content .= $imageLinkOpen . "<img src='" . $imagePath . "' width='" . $slider_width . "' " . $slider_height_att . " alt='" . $title . "' title='" . $title . "' data-transition='" . $effect . "' />" . $imageLinkClose;
                }
            }
            //end IF
        }
        // END FOR EACH
        $preHTML = "<div class=\"slider-wrapper theme-default\">\r\n\t\t\t\t\t<div class=\"ribbon\"></div>\r\n\t\t\t\t\t<div id=\"slider\" class=\"nivoSlider\"  style=\"max-width:" . $slider_width . "px\">";
        $postHTML = "</div>\n</div>";
        return $preStyle . $preHTML . $content . $postHTML;
    }
    // END IF
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:101,代码来源:slideshow.php

示例5: the_permalink

">
						<!-- BEGIN .post-content -->
						<div class="post-content clearfix">
							<div class="post-thumb">
								<?php 
            if (has_post_thumbnail()) {
                ?>
									<div class="post-thumb">
										<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                resize_img("width=280&height=140");
                ?>
</a>
									</div>
								<?php 
            }
            ?>
							</div>
							<h4 class="entry-title"><a href="<?php 
            the_permalink();
            ?>
" rel="bookmark" title="<?php 
            the_title();
            ?>
"><?php 
            the_title();
开发者ID:Hevix,项目名称:hevix,代码行数:31,代码来源:related-portfolio.php

示例6: session_start

<?php

session_start();
include_once 'includes/connect.php';
include_once 'includes/functions.php';
$title = 'Danny\'s site';
?>
<html>
    <head>
        <title><?php 
echo $title;
?>
</title>
        <link rel="stylesheet" href="includes/style.css" type="text/css">
    </head>
    <body>
    <div id="wrapper">
    <center><a href="http://danny.com"><?php 
echo resize_img('includes/header.png');
?>
</a></center>
    <div id="content">
<a href="signin.php">signin</a> | <a href="signup.php">signup</a><br />
开发者ID:OmgImAlexis,项目名称:public_html,代码行数:23,代码来源:header.php

示例7: while

 $target_file = './' . $dir['images'] . $clean_file;
 if (file_exists($target_file)) {
     $i = 2;
     while (file_exists($target_file) && $i < 100) {
         $clean_file_name = friendly_url($source_file['filename']) . '-' . $i;
         $clean_file = $clean_file_name . '.' . $clean_file_ext;
         $target_file = './' . $dir['images'] . $clean_file;
         $i++;
     }
 }
 move_uploaded_file($_FILES['file']['tmp_name'], $target_file);
 list($img_width, $img_height) = getimagesize($target_file);
 if (isset($img_width) && !empty($img_width) && isset($img_height) && !empty($img_height)) {
     $thumb_size = isset($conf['admin_thumb_size']) && is_numeric($conf['admin_thumb_size']) ? $conf['admin_thumb_size'] : $default['thumb_size'];
     #if ($img_width > $thumb_size || $img_height > $thumb_size) {
     resize_img($target_file, $thumb_size, './' . $dir['thumbs'] . '_' . $clean_file);
     #}
     $files_file = file($file['files']);
     $files_file_lines = '';
     foreach ($files_file as $single_line) {
         $file_data = explode(DELIMITER, $single_line);
         if (substr($file_data[0], 0, 2) == '<?') {
             $auto_increment_id = trim($file_data[1]);
         } else {
             $files_file_lines .= $single_line;
         }
     }
     $file_size = filesize($target_file);
     $files_file_content = SAFETY_LINE . DELIMITER . ($auto_increment_id + 1) . "\n" . $files_file_lines;
     $files_file_content .= $auto_increment_id . DELIMITER . $clean_file_name . DELIMITER . $clean_file_ext . DELIMITER . $file_size . DELIMITER . mn_time() . DELIMITER . 'images' . DELIMITER . $img_width . DELIMITER . $img_height . DELIMITER . $_SESSION['mn_user_id'] . DELIMITER . $file_gallery . DELIMITER . $file_folder . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . DELIMITER . '' . "\n";
     mn_put_contents($file['files'], $files_file_content);
开发者ID:deanbrabec,项目名称:news_slider,代码行数:31,代码来源:mn-files.php

示例8: elseif

								<?php 
            }
            ?>
									</div>
								<?php 
        } elseif (has_post_thumbnail()) {
            ?>
									<div class="post-thumb">
										<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
" ><?php 
            resize_img("width=205&height=140");
            ?>
</a>
									</div>
								<?php 
        }
        ?>
								<h2 class="entry-title"><a href="<?php 
        the_permalink();
        ?>
" rel="bookmark" title="<?php 
        the_title();
        ?>
"><?php 
        the_title();
        ?>
开发者ID:Hevix,项目名称:hevix,代码行数:31,代码来源:template-portfolio-four-columns.php

示例9: json_encode

    	$custom_error['jquery-upload-file-error']="File already exists";
    	echo json_encode($custom_error);
    	die();
    */
    $error = $_FILES["file"]["error"];
    //You need to handle  both cases
    //If Any browser does not support serializing of multiple files using FormData()
    if (!is_array($_FILES["file"]["name"])) {
        $fileName = $_FILES["file"]["name"];
        move_uploaded_file($_FILES["file"]["tmp_name"], $output_dir . $fileName);
        $imgSize = getimagesize($output_dir . $fileName);
        if ($imgSize[0] > 600) {
            resize_img($output_dir, $fileName, $output_dir, 600, '');
        }
        resize_img($output_dir, $fileName, $thumbs_dir, 100, 'thumb');
        $ret[] = $fileName;
    } else {
        $fileCount = count($_FILES["file"]["name"]);
        for ($i = 0; $i < $fileCount; $i++) {
            $fileName = $_FILES["file"]["name"][$i];
            move_uploaded_file($_FILES["file"]["tmp_name"][$i], $output_dir . $fileName);
            $imgSize = getimagesize($output_dir . $fileName);
            if ($imgSize[0] > 600) {
                resize_img($output_dir, $fileName, $output_dir, 600, '');
            }
            resize_img($output_dir, $fileName, $thumbs_dir, 100, 'thumb');
            $ret[] = $fileName;
        }
    }
    echo json_encode($ret);
}
开发者ID:amriterry,项目名称:ptn,代码行数:31,代码来源:uploadImg.php

示例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;
}
开发者ID:agolomazov,项目名称:generator,代码行数:73,代码来源:functions.php

示例11: explode

        $tmp_thumb = explode('.', $filename);
        $thumb = '';
        $cnt = count($tmp_thumb) - 1;
        for ($i = 0; $i < $cnt; $i++) {
            $thumb .= $tmp_thumb[$i];
        }
        $tmp_thumb = $thumb;
        $i = 0;
        while (file_exists("{$path}{$thumb}.{$format}")) {
            $i++;
            $thumb = "{$tmp_thumb}_copy{$i}";
        }
        $filename = "{$thumb}.{$format}";
        $targetFile = "{$path}{$filename}";
        if ($_FILES['Filedata']['size'] > $config['size']) {
            die(ERROR_SAVE_FILE_3);
        }
        if (!move_uploaded_file($tempFile, $targetFile)) {
            die(ERROR_SAVE_FILE_2);
        }
        if (format($filename, 1, '.jpg.jpeg.gif.png')) {
            resize_img($path, $filename, $thumb, $config);
            die('1');
        }
        die('1');
    } else {
        die(ERROR_SAVE_FILE_1);
    }
} else {
    die('PERMISSION DENIED');
}
开发者ID:pioytazsko,项目名称:garantmarket,代码行数:31,代码来源:uploadify.php

示例12: imagedestroy

        imagedestroy($dst);
        return FALSE;
    }
    $res = FALSE;
    
    switch($type) {
        case IMAGETYPE_GIF:
            $res	= imagegif($dst, $destination);
            break;
        case IMAGETYPE_JPEG:
            $res	= imagejpeg($dst, $destination, 100);
            break;
        case IMAGETYPE_PNG:
            $res	= imagepng($dst, $destination);
            break;
    }
    imagedestroy($src_copy);
    imagedestroy($dst);
    if( ! $res ) {
        return FALSE;
    }
    
    if( ! file_exists($destination) ) {
        return FALSE;
    }
    chmod( $destination, 0777 );
    return TRUE;
    */
}
resize_img('aaa.jpg', '', 120, 80);
//echo 'OK';
开发者ID:chaobj001,项目名称:tt,代码行数:31,代码来源:resize_img.php

示例13: die

    $save_path = "{$path}{$filename}.{$type}";
    if (copy($image, $save_path)) {
        if (filesize($save_path) > $config['size']) {
            $die = '
			<script type="text/javascript">
				with(window.top){
					popupMenu({title: lng.ERROR, main: \'<p class="center">\' + lng.SAVE_FILE_ERROR_3 + "</p>"});
				}
				if(parent){
					parent.pixlr.overlay.hide();
				}
			</script>
			 ';
            die($die);
        }
        resize_img("{$folder}{$path}", "{$filename}.{$type}", $filename, $config);
        echo '
		<script type="text/javascript">
			with(window.top){
				getDir(realPath);
				setView();
			}
			if(parent) parent.pixlr.overlay.hide();
		</script>
		 ';
    } else {
        echo '
		<script type="text/javascript">
			with(window.top){
				popupMenu({title: lng.ERROR, main: \'<p class="center">\' + lng.SAVE_FILE_ERROR_2 + "</p>"});
			}
开发者ID:pioytazsko,项目名称:garantmarket,代码行数:31,代码来源:save_image.php

示例14: unlink

        } else {
            if ($imageinfo[0] < 100 && $_SESSION['epUser']['parent'] != 2) {
                $error = 'Image must be wider than 100 pixels.';
                unlink($file_path . $temp_id);
            } else {
                $image_title = mysql_real_escape_string(preg_replace(array('/\\.([a-z0-9]+)$/i', '/[^a-z0-9]+/i'), array('', '-'), $_FILES[$element]['name']));
                $image_position = dbq("SELECT MAX(`position`) AS `position` FROM `wp_image_gallery` WHERE `parent` = {$parentID}");
                if (!is_array($image_position)) {
                    $image_position = 1;
                } else {
                    $image_position = $image_position[0]['position'] + 1;
                }
                $insert_id = dbq("INSERT INTO `wp_image_gallery` (`parent`, `title`, `position`) VALUES ('{$parentID}', '{$image_title}', '{$image_position}')");
                dbq("UPDATE wp_structure SET modified = NOW() WHERE id = {$parentID}");
                foreach ($cfg['img'] as $img_key => $img_val) {
                    resize_img($file_path . $temp_id, $file_path . "{$insert_id}-{$img_key}.jpg", $cfg['img'][$img_key][0], $cfg['img'][$img_key][1], $cfg['img'][$img_key][2], $cfg['img'][$img_key][3], $cfg['img'][$img_key][4], $cfg['img'][$img_key][5], $cfg['img'][$img_key][6], $cfg['img'][$img_key][7]);
                }
                /*
                resize_img ($file_path . $temp_id, $file_path . "{$insert_id}-s.jpg", $cfg['img']['small'][0], $cfg['img']['small'][1], $cfg['img']['small'][2], $cfg['img']['small'][3], $cfg['img']['small'][4], $cfg['img']['small'][5], $cfg['img']['small'][6], $cfg['img']['small'][7]);
                resize_img ($file_path . $temp_id, $file_path . "{$insert_id}-m.jpg", $cfg['img']['medium'][0], $cfg['img']['medium'][1], $cfg['img']['medium'][2], $cfg['img']['medium'][3], $cfg['img']['medium'][4], $cfg['img']['medium'][5], $cfg['img']['medium'][6], $cfg['img']['medium'][7]);
                resize_img ($file_path . $temp_id, $file_path . "{$insert_id}-l.jpg", $cfg['img']['large'][0], $cfg['img']['large'][1], $cfg['img']['large'][2], $cfg['img']['large'][3], $cfg['img']['large'][4], $cfg['img']['large'][5], $cfg['img']['large'][6], $cfg['img']['large'][7]);
                */
                unlink($file_path . $temp_id);
                $msg = 'SUCCESS';
            }
        }
    } else {
        $error = 'File upload error!';
    }
} else {
    if ($element == 'jq-files' || $element == 'jq-files1' || $element == 'jq-files2' || $element == 'jq-files3') {
开发者ID:nukem,项目名称:WorkSound,代码行数:31,代码来源:doajaxfileupload.php

示例15: opendir

$thumb_path = "../../contents/thumbs/";
require "../../includes/functions.inc.php";
if (is_dir($path)) {
    $dir_handle = opendir($path);
    $img = array();
    $i = 0;
    while (($dir = readdir()) !== false) {
        if (is_dir($dir)) {
            continue;
        } else {
            $extensions = array('jpg', 'jpeg', 'png', 'gif');
            if (in_array(get_ext($dir), $extensions)) {
                $img[$i]['imgName'] = $dir;
                $imgSize = getimagesize($path . $dir);
                $img[$i]['imgWidth'] = $imgSize[0];
                $img[$i]['imgHeight'] = $imgSize[1];
                $img[$i]['imgPath'] = $path . $dir;
                $img[$i]['thumbPath'] = $thumb_path . $dir . '.thumb.' . get_ext($dir);
                $img[$i]['fileSize'] = filesize($path . $dir);
                if (!file_exists($img[$i]['thumbPath'])) {
                    resize_img($path, $dir, $thumb_path, 100, 'thumb');
                }
                $i++;
            } else {
                continue;
            }
        }
    }
    closedir();
    echo json_encode($img);
}
开发者ID:amriterry,项目名称:ptn,代码行数:31,代码来源:getImgList.php


注:本文中的resize_img函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。