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


PHP exif_thumbnail函数代码示例

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


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

示例1: thumb_href

 private function thumb_href($source_path, $width, $height)
 {
     if (!file_exists($source_path)) {
         return null;
     }
     $name = 'thumb-' . sha1($source_path) . '-' . $width . 'x' . $height . '.jpg';
     $thumb_path = $this->thumbs_path . '/' . $name;
     $thumb_href = $this->thumbs_href . '/' . $name;
     if (!file_exists($thumb_path) || filemtime($source_path) >= filemtime($thumb_path)) {
         $image = new Image();
         $et = false;
         if ($this->setup->get('HAS_PHP_EXIF') && $this->context->query_option('thumbnails.exif', false) === true && $height != 0) {
             $et = @exif_thumbnail($source_path);
         }
         if ($et !== false) {
             file_put_contents($thumb_path, $et);
             $image->set_source($thumb_path);
             $image->normalize_exif_orientation($source_path);
         } else {
             $image->set_source($source_path);
         }
         $image->thumb($width, $height);
         $image->save_dest_jpeg($thumb_path, 80);
     }
     return file_exists($thumb_path) ? $thumb_href : null;
 }
开发者ID:Txuritan,项目名称:h5ai,代码行数:26,代码来源:class-thumb.php

示例2: thumb_href

 private function thumb_href($source_abs_path, $mode, $width, $height)
 {
     if (!file_exists($source_abs_path)) {
         return null;
     }
     if (!is_dir($this->thumbs_path)) {
         @mkdir($this->thumbs_path, 0755, true);
     }
     $name = "thumb-" . sha1("{$source_abs_path}-{$width}-{$height}-{$mode}") . ".jpg";
     $thumb_abs_path = $this->thumbs_path . "/" . $name;
     $thumb_abs_href = $this->thumbs_href . "/" . $name;
     if (!file_exists($thumb_abs_path) || filemtime($source_abs_path) >= filemtime($thumb_abs_path)) {
         $image = new Image();
         $et = false;
         $opts = $this->app->get_options();
         if ($opts["thumbnails"]["exif"] === true && function_exists("exif_thumbnail")) {
             $et = @exif_thumbnail($source_abs_path);
         }
         if ($et !== false) {
             file_put_contents($thumb_abs_path, $et);
             $image->set_source($thumb_abs_path);
             $image->normalize_exif_orientation($source_abs_path);
         } else {
             $image->set_source($source_abs_path);
         }
         $image->thumb($mode, $width, $height);
         $image->save_dest_jpeg($thumb_abs_path, 80);
     }
     return file_exists($thumb_abs_path) ? $thumb_abs_href : null;
 }
开发者ID:kirkdwilson,项目名称:LibraryBox-h5ai-Interface,代码行数:30,代码来源:Thumb.php

示例3: thumb_href

 private function thumb_href($source_path, $width, $height)
 {
     if (!file_exists($source_path)) {
         return null;
     }
     $name = "thumb-" . sha1("{$source_path}") . "-" . $width . "x" . $height . ".jpg";
     $thumb_path = $this->thumbs_path . "/" . $name;
     $thumb_url = $this->thumbs_href . "/" . $name;
     if (!file_exists($thumb_path) || filemtime($source_path) >= filemtime($thumb_path)) {
         $image = new Image();
         $et = false;
         $opts = $this->app->get_options();
         if (HAS_PHP_EXIF && $opts["thumbnails"]["exif"] === true && $height != 0) {
             $et = @exif_thumbnail($source_path);
         }
         if ($et !== false) {
             file_put_contents($thumb_path, $et);
             $image->set_source($thumb_path);
             $image->normalize_exif_orientation($source_path);
         } else {
             $image->set_source($source_path);
         }
         $image->thumb($width, $height);
         $image->save_dest_jpeg($thumb_path, 80);
     }
     return file_exists($thumb_path) ? $thumb_url : null;
 }
开发者ID:kirkdwilson,项目名称:LibraryBox-h5ai-Interface,代码行数:27,代码来源:class-thumb.php

示例4: __construct

 function __construct($image, $isfile = false)
 {
     if (!empty($image) || $this->filename !== null) {
         if (is_readable($this->filename) && function_exists('exif_thumbnail') && in_array(image_type_to_mime_type(exif_imagetype($this->filename)), array('image/jpeg', 'image/tiff'))) {
             $this->thumb = @exif_thumbnail($this->filename);
             if (trim($this->thumb) == "") {
                 $this->thumb = NULL;
             }
         }
         $this->classname = get_class($this);
         if ($isfile) {
             $this->filename = $image;
         } else {
             $this->data = $image;
         }
     }
 }
开发者ID:railfuture,项目名称:tiki-website,代码行数:17,代码来源:abstract.php

示例5: ExtractEXIFgetImageSize

 function ExtractEXIFgetImageSize()
 {
     if ($this->getimagesizeinfo = @GetImageSize($this->sourceFilename)) {
         $this->source_width = $this->getimagesizeinfo[0];
         $this->source_height = $this->getimagesizeinfo[1];
         if (function_exists('exif_thumbnail') && $this->getimagesizeinfo[2] == 2) {
             // Extract EXIF info from JPEGs
             $this->exif_thumbnail_width = '';
             $this->exif_thumbnail_height = '';
             $this->exif_thumbnail_type = '';
             // The parameters width, height and imagetype are available since PHP v4.3.0
             if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
                 $this->exif_thumbnail_data = @exif_thumbnail($this->sourceFilename, $this->exif_thumbnail_width, $this->exif_thumbnail_height, $this->exif_thumbnail_type);
             } else {
                 // older versions of exif_thumbnail output an error message but NOT return false on failure
                 ob_start();
                 $this->exif_thumbnail_data = exif_thumbnail($this->sourceFilename);
                 $exit_thumbnail_error = ob_get_contents();
                 ob_end_clean();
                 if (empty($exit_thumbnail_error) && !empty($this->exif_thumbnail_data)) {
                     if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false)) {
                         $this->exif_thumbnail_width = ImageSX($gdimg_exif_temp);
                         $this->exif_thumbnail_height = ImageSY($gdimg_exif_temp);
                         $this->exif_thumbnail_type = 2;
                         // (2 == JPEG) before PHP v4.3.0 only JPEG format EXIF thumbnails are returned
                         unset($gdimg_exif_temp);
                     } else {
                         $this->ErrorImage('Failed - $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data) in ' . __FILE__ . ' on line ' . __LINE__);
                     }
                 }
             }
         }
         // see if EXIF thumbnail can be used directly with no processing
         if (!empty($this->exif_thumbnail_data)) {
             while (true) {
                 if (!empty($this->xto)) {
                     if (isset($this->w) && $this->w != $this->exif_thumbnail_width) {
                         break;
                     }
                     if (isset($this->h) && $this->h != $this->exif_thumbnail_height) {
                         break;
                     }
                     $CannotBeSetParameters = array('sx', 'sy', 'sh', 'sw', 'bw', 'bg', 'bc', 'usa', 'usr', 'ust', 'wmf', 'wmp', 'wmm', 'wma');
                     foreach ($CannotBeSetParameters as $parameter) {
                         if (!empty($this->{$parameter})) {
                             break 2;
                         }
                     }
                 }
                 if (!empty($this->xto) && empty($this->phpThumbDebug)) {
                     // write cached file
                     $ImageTypesLookup = array(2 => 'jpeg');
                     // EXIF thumbnails are (currently?) only availble from JPEG source images
                     if (is_dir($this->config_cache_directory) && is_writable($this->config_cache_directory) && isset($ImageTypesLookup[$this->exif_thumbnail_type])) {
                         $cache_filename = $this->GenerateCachedFilename($ImageTypesLookup[$this->exif_thumbnail_type]);
                         if (is_writable($cache_filename)) {
                             if ($fp_cached = @fopen($cache_filename, 'wb')) {
                                 fwrite($fp_cached, $this->exif_thumbnail_data);
                                 fclose($fp_cached);
                             }
                         }
                     }
                     if ($mime_type = ImageTypeToMIMEtype($this->exif_thumbnail_type)) {
                         header('Content-type: ' . $mime_type);
                         echo $this->exif_thumbnail_data;
                         exit;
                     } else {
                         $this->ErrorImage('ImageTypeToMIMEtype(' . $this->exif_thumbnail_type . ') failed in ' . __FILE__ . ' on line ' . __LINE__);
                     }
                 }
                 break;
             }
         }
         if ($this->config_max_source_pixels > 0 && $this->source_width * $this->source_height > $this->config_max_source_pixels) {
             // Source image is larger than would fit in available PHP memory
             if (!empty($this->exif_thumbnail_data)) {
                 // EXIF thumbnail exists, and will be use as source image
                 $this->gdimg_source = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data);
                 $this->source_width = $this->exif_thumbnail_width;
                 $this->source_height = $this->exif_thumbnail_height;
                 // override allow-enlarging setting if EXIF thumbnail is the only source available
                 // otherwise thumbnails larger than the EXIF thumbnail will be created at EXIF size
                 $this->config_output_allow_enlarging = true;
             } else {
                 // EXIF thumbnail is unavailable
                 // if ImageMagick is installed, use it to thumbnail,
                 // otherwise no choice but to abort
                 if ($this->ImageMagickThumbnailToGD()) {
                     // excellent, we have a thumbnail
                 } else {
                     $this->ErrorImage('Source image is more than ' . sprintf('%1.1f', $this->config_max_source_pixels / 1000000) . ' megapixels - insufficient memory.' . "\n" . 'EXIF thumbnail unavailable.');
                 }
             }
         }
     }
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:97,代码来源:phpthumb.class.php

示例6: auth

// access a file in a user's directory
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/main_func.php';
auth();
$file = IMAGEBASEDIR . $_GET['file'];
preg_match("/^\\d{1,11}\\//", $_GET['file'], $project);
$project = str_replace('/', '', $project[0]);
$user = $_SESSION['user_id'];
// apply your logic here
$userCanDownloadThisFile = in_array($project, $_SESSION['projects']);
if (file_exists($file) && $userCanDownloadThisFile && underPath($file)) {
    $ext = pathinfo($file, PATHINFO_EXTENSION);
    if (array_key_exists('thumb', $_GET) && in_array($ext, array('jpg', 'gif', 'png')) && filesize($file) > 5000) {
        header('Content-Type: image/jpeg');
        if ($ext == 'jpg') {
            echo exif_thumbnail($file);
        } else {
            if ($ext == 'png' || $ext == 'gif') {
                $img = $ext == 'png' ? imagecreatefrompng($file) : imagecreatefromgif($file);
                $width = imagesx($img);
                $height = imagesy($img);
                $new_height = 100;
                $new_width = $width * $new_height / $height;
                $thumb_img = imagecreatetruecolor($new_width, $new_height);
                imagecopyresampled($thumb_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                imagedestroy($img);
                imagejpeg($thumb_img);
                imagedestroy($thumb_img);
            }
        }
    } else {
开发者ID:debruine,项目名称:webmorph,代码行数:30,代码来源:fileAccess.php

示例7: dirname

<?php

/*
  test1.jpg is a 1*1 image that does not contain any Exif/Comment information
  test2.jpg is the same image but contains Exif/Comment information and a
            copy of test1.jpg as a thumbnail.
*/
$infile = dirname(__FILE__) . '/test1.jpg';
echo md5_file($infile) . '_' . filesize($infile);
$thumb = exif_thumbnail(dirname(__FILE__) . '/test2.jpg');
echo " == ";
echo md5($thumb) . '_' . strlen($thumb);
echo "\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:exif002.php

示例8: Header

<?php

Header('Content-type: image/tiff');
echo exif_thumbnail('p0004557.jpg');
开发者ID:SandyS1,项目名称:presentations,代码行数:4,代码来源:exif_thumb.php

示例9: basename

$target_path = $target_path . basename($_FILES['archivo']['name']);
if (move_uploaded_file($_FILES['archivo']['tmp_name'], $target_path)) {
    $jsondata['success'] = "El archivo " . basename($_FILES['archivo']['name']) . " ha sido subido";
} else {
    $jsondata['error'] = error_get_last();
    //echo "Ha ocurrido un error, trate de nuevo!";
}
$archivador = "./images/" . $jsondata['nombre_archivo'];
//$v_imagen = $target_path.$_FILES['archivo']['name'];
$v_imagen = "../images/" . $jsondata['nombre_archivo'];
$jsondata['v_imagen'] = $v_imagen;
// Generar thumbnail.
$v_ancho_imagen = 1234;
$v_alto_imagen = 800;
$v_tipo_imagen = 'jpg';
$v_thumbnail = exif_thumbnail($v_imagen, $v_ancho_imagen, $v_alto_imagen, $v_tipo_imagen);
$v_exif = exif_read_data($v_imagen);
$v_longitud = getGps($v_exif["GPSLongitude"], $v_exif['GPSLongitudeRef']);
$v_latitud = getGps($v_exif["GPSLatitude"], $v_exif['GPSLatitudeRef']);
$jsondata['latitud'] = "La latitud de la imagen es: " . $v_latitud;
$jsondata['longitud'] = "La longitud de la imagen es: " . $v_longitud;
$query = "INSERT INTO TIO_IMAGENES(direccion_imagen,latitud_imagen,longitud_imagen) VALUES('{$archivador}',{$v_latitud},{$v_longitud})";
if ($conn->query($query) === TRUE) {
    $jsondata['success'] = "El archivo se ha subido correctamente al servidor";
} else {
    $jsondata['success'] = "Error al subir archivo: " . $conn->error;
}
function getGps($exifCoord, $hemi)
{
    $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
    $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
开发者ID:JosueTC94,项目名称:Myphoto,代码行数:31,代码来源:subir_imagen.php

示例10: extractEmbeddedThumbnail

 /** 
  * Extracts the embedded thumbnail picture of a jpeg or tiff image
  * 
  * @return	string		thumbnail 
  */
 protected function extractEmbeddedThumbnail()
 {
     if (!function_exists('exif_thumbnail')) {
         return false;
     }
     $width = $height = $type = 0;
     $thumbnail = @exif_thumbnail($this->sourceFile, $width, $height, $type);
     if ($thumbnail && $type && $width && $height) {
         // resize the extracted thumbnail again if necessary
         // (normally the thumbnail size is set to 160px
         // which is recommended in EXIF >2.1 and DCF)
         $this->mimeType = image_type_to_mime_type($type);
         if (!$this->checkSize($width, $height)) {
             // get temporary file name
             $this->sourceFile = FileUtil::getTemporaryFilename('thumbnail_');
             // create tmp file
             $tmpFile = new File($this->sourceFile);
             $tmpFile->write($thumbnail);
             $tmpFile->close();
             unset($thumbnail, $tmpFile);
             // resize tmp file again
             return $this->makeThumbnail(true);
         }
         return $thumbnail;
     }
     return false;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:32,代码来源:Thumbnail.class.php

示例11: getThumbnail

 public function getThumbnail()
 {
     return exif_thumbnail($this->sFilename);
 }
开发者ID:cnlpete,项目名称:image-metadata-parser,代码行数:4,代码来源:imageMetadataParser.php

示例12: loadExifThumbnail

 /**
  * Load exif thumbnail
  * We can load thumbnail only if we want because in loadExifData() in
  * function read_exif_data() parameter $read_thumbnail = false
  */
 protected function loadExifThumbnail()
 {
     if (is_array($this->exifData) && array_key_exists('THUMBNAIL', $this->exifData)) {
         // read an exif data
         // exif_thumbnail($filename, $width, $height, $imagetype)
         $this->exifThumbnail = exif_thumbnail($this->file, $this->tnWidth, $this->tnHeight, $this->tnType);
     }
 }
开发者ID:rajanishtimes,项目名称:partnerapi,代码行数:13,代码来源:ExifReader.php

示例13: exif_thumbnail

<?php

if (array_key_exists('file', $_REQUEST)) {
    $image = exif_thumbnail($_REQUEST['file'], $width, $height, $type);
} else {
    $image = false;
}
if ($image !== false) {
    header('Content-type: ' . image_type_to_mime_type($type));
    echo $image;
    exit;
} else {
    // no thumbnail available, handle the error here
    echo 'No thumbnail available';
}
开发者ID:xinlingever,项目名称:moviemaker,代码行数:15,代码来源:b.php

示例14: exif_thumbnail

<?php

$filename = 'test/images/test1pix.jpg';
$image = exif_thumbnail($filename, $width, $height, $type);
if ($image !== false) {
    header('Content-type: ' . image_type_to_mime_type($type));
    var_dump($width, $height, $type);
} else {
    echo 'No thumbnail available';
}
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:1793.php

示例15: _resizeTo

	/**
	 * Resize this image and save the output as another File object.
	 *
	 * This is used on conjunction with getPreview* and getQuickPreview.
	 * QuickPreview creates the destination file in the correct directory
	 * and getPreview* methods request the actual resizing.
	 *
	 * @param Filestore\File $file   The destination file
	 * @param int            $width  Width of the final image (in px)
	 * @param int            $height Height of the final image (in px)
	 * @param string         $mode   Mode (part of the geometry)
	 */
	private function _resizeTo(Filestore\File $file, $width, $height, $mode){

		if(!$this->isImage()){
			// :/
			return;
		}

		\Core\Utilities\Logger\write_debug('Resizing image ' . $this->getFilename('') . ' to ' . $width . 'x' . $height . $mode);

		$m = $this->getMimetype();

		// Make sure the directory of the destination file exists!
		// By touching the file, Core will create all parent directories as necessary.
		$file->putContents('');

		if($m == 'image/gif' && exec('which convert 2>/dev/null')){
			// The GIF resizer handles EVERYTHING :)
			// Granted of course, that imagemagick's convert is available on the server.
			$resize = escapeshellarg($mode . $width . 'x' . $height);
			exec('convert ' . escapeshellarg($this->getFilename()) . ' -resize ' . $resize . ' ' . escapeshellarg($file->getFilename()));

			\Core\Utilities\Logger\write_debug('Resizing complete (via convert)');
			return;
		}

		// Traditional resizing logic.
		switch ($m) {
			case 'image/jpeg':
				$thumbType = 'JPEG';
				$thumbWidth = $width;
				$thumbHeight = $height;
				if($width <= 200 && $height <= 200 && function_exists('exif_thumbnail')){
					// Try to write out from the thumbnail img instead of the full size.
					// This is done to increase server performance.
					// eg: resizing a 5MB JPEG can take upwards of 50-100ms,
					// whereas the embedded thumbnail will take only 2-10ms.
					// Not to mention professional JPEG management tools such as PS and Gimp
					// produce marginally higher-quality thumbnails than GD will.
					// (The resulting filesize is negligible.)
					// Of course if the requested image is larger than a thumbnail size, (200x200 in this case),
					// using the thumbnail is counter-productive!
					$img = exif_thumbnail($this->getFilename(), $thumbWidth, $thumbHeight, $thumbType);
					if($img){
						\Core\Utilities\Logger\write_debug('JPEG has thumbnail data of ' . $thumbWidth . 'x' . $thumbHeight . '!');
						$file->putContents($img);
						$img = imagecreatefromjpeg($file->getFilename());
					}
					else{
						$img = imagecreatefromjpeg($this->getFilename());
					}
				}
				else{
					$img = imagecreatefromjpeg($this->getFilename());
				}

				break;
			case 'image/png':
				$img = imagecreatefrompng($this->getFilename());
				break;
			case 'image/gif':
				$img = imagecreatefromgif($this->getFilename());
				break;
			default:
				// Hmmm...
				\Core\Utilities\Logger\write_debug('Resizing complete (failed, not sure what it was)');
				return;
		}
		if ($img) {
			$sW = imagesx($img);
			$sH = imagesy($img);

			$nW = $sW;
			$nH = $sH;


			switch($mode){
				// Standard mode, images are scaled down (only) while preserving aspect ratio
				case '':
				case '<':
					if ($nW > $width) {
						$nH = $width * $sH / $sW;
						$nW = $width;
					}

					if ($nH > $height) {
						$nW = $height * $sW / $sH;
						$nH = $height;
					}
//.........这里部分代码省略.........
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:101,代码来源:FileLocal.php


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