• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP exif_imagetype函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: upload

 /**
  * Upload an image.
  *
  * @param $file
  * @return array
  */
 public function upload(array $file)
 {
     if (!$file) {
         $status = ['status' => 'error', 'message' => GENERIC_UPLOAD_ERROR_MESSAGE];
         return $status;
     }
     $tempName = $file['tmp_name'];
     if (is_null($tempName)) {
         $status = ['status' => 'error', 'message' => GENERIC_UPLOAD_ERROR_MESSAGE];
         return $status;
     }
     $imageInfo = getimagesize($tempName);
     if (!$imageInfo) {
         $status = ['status' => 'error', 'message' => 'Only images are allowed'];
         return $status;
     }
     $fileType = image_type_to_mime_type(exif_imagetype($tempName));
     if (!in_array($fileType, $this->_allowedTypes)) {
         $status = ['status' => 'error', 'message' => 'File type not allowed'];
         return $status;
     }
     $fileName = htmlentities($file['name']);
     $height = $this->_imagick->getImageHeight();
     $width = $this->_imagick->getImageWidth();
     $uploadPath = $_SERVER['DOCUMENT_ROOT'] . PROPERTY_IMG_TMP_DIR;
     if (!move_uploaded_file($tempName, $uploadPath . "/{$fileName}")) {
         $status = ['status' => 'error', 'message' => 'Can\'t move file'];
         return $status;
     }
     $status = ['status' => 'success', 'url' => PROPERTY_IMG_TMP_DIR . '/' . $fileName, 'width' => $width, 'height' => $height, 'token' => $_SESSION['csrf_token']];
     return $status;
 }
开发者ID:justincdotme,项目名称:bookme,代码行数:38,代码来源:ImageUpload.php


示例2: yukle

function yukle($hedef = NULL, $alan = 'file')
{
    $yuklenen = F3::get("FILES.{$alan}.tmp_name");
    // hedef ve yüklenen dosyanın boş olmasına izin veriyoruz
    // herhangi biri boşsa mesele yok, çağırana dön
    if (empty($hedef) || empty($yuklenen)) {
        return true;
    }
    // bu bir uploaded dosya olmalı, fake dosyalara izin yok
    if (is_uploaded_file($yuklenen)) {
        // boyutu sınırla, değeri öylesine seçtim
        if (filesize($yuklenen) > 600000) {
            F3::set('error', 'Resim çok büyük');
        } else {
            if (exif_imagetype($yuklenen) != IMAGETYPE_JPEG) {
                F3::set('error', 'Resim JPEG değil');
            } else {
                if (file_exists($hedef)) {
                    F3::set('error', 'Resim zaten kaydedilmiş');
                } else {
                    if (!move_uploaded_file($yuklenen, $hedef)) {
                        F3::set('error', 'Dosya yükleme hatası');
                    }
                }
            }
        }
        // yok başka bir ihtimal!
    } else {
        // bu aslında bir atak işareti
        F3::set('error', 'Dosya geçerli bir yükleme değil');
    }
    return false;
}
开发者ID:seyyah,项目名称:uzkay,代码行数:33,代码来源:kaydet.php


示例3: setFile

 private function setFile($file)
 {
     $errorCode = $file['error'];
     if ($errorCode === UPLOAD_ERR_OK) {
         $type = exif_imagetype($file['tmp_name']);
         if ($type) {
             $extension = image_type_to_extension($type);
             $src = 'img/' . date('YmdHis') . '.original' . $extension;
             if ($type == IMAGETYPE_GIF || $type == IMAGETYPE_JPEG || $type == IMAGETYPE_PNG) {
                 if (file_exists($src)) {
                     unlink($src);
                 }
                 $result = move_uploaded_file($file['tmp_name'], $src);
                 if ($result) {
                     $this->src = $src;
                     $this->type = $type;
                     $this->extension = $extension;
                     $this->setDst();
                 } else {
                     $this->msg = 'Failed to save file';
                 }
             } else {
                 $this->msg = 'Please upload image with the following types: JPG, PNG, GIF';
             }
         } else {
             $this->msg = 'Please upload image file';
         }
     } else {
         $this->msg = $this->codeToMessage($errorCode);
     }
 }
开发者ID:vfssantos,项目名称:belle_server,代码行数:31,代码来源:crop.php


示例4: convert

 public function convert($source = '')
 {
     if (!empty($source)) {
         $this->source = $source;
     }
     if (empty($this->source) || !file_exists($this->source)) {
         $this->error(1, 'The source file "' . $this->source . '" is missing');
         return false;
     }
     switch (exif_imagetype($this->source)) {
         case IMAGETYPE_GIF:
             $result = $this->_convertImage($this->source, 'gif');
             break;
         case IMAGETYPE_JPEG:
             $result = $this->_convertImage($this->source, 'jpg');
             break;
         case IMAGETYPE_PNG:
             $result = $this->_convertImage($this->source, 'png');
             break;
         case IMAGETYPE_BMP:
             $result = $this->image = file_get_contents($this->source);
             break;
         default:
             $this->error(2, 'Unsupported file type');
             return false;
     }
     return $result;
 }
开发者ID:askzap,项目名称:ultimate,代码行数:28,代码来源:class.convert_to_bmp.php


示例5: filter

 public function filter($value)
 {
     $img_orig = $this->_createImage($value);
     $img_new = $this->_grayscaleImage($img_orig);
     $this->_outputImage($img_new, exif_imagetype($value), $value);
     return $value;
 }
开发者ID:hexdoll,项目名称:Image-Filter,代码行数:7,代码来源:Grayscale.php


示例6: __construct

 /**
  * 构造函数
  * @param array $files 要处理的图片列表
  */
 public function __construct(array $files = array())
 {
     //名称生成方式
     $this->namecall = function ($name) {
         return 'Other/' . $name . '-' . md5($name);
     };
     //设置文件信息
     foreach ($files as $key => $file) {
         //对文件名中的空格做处理
         $filename = str_replace(' ', '%20', $file);
         //取得文件的大小信息
         if (false !== ($this->infos[$file] = getimagesize($filename))) {
             //取得扩展名
             //支持格式 see http://www.php.net/manual/zh/function.exif-imagetype.php
             $this->infos[$file]['ext'] = image_type_to_extension(exif_imagetype($filename), 0);
             //如果不在允许的图片类型范围内
             if (!in_array($this->infos[$file]['ext'], $this->exts)) {
                 unset($this->infos[$file]);
             }
         } else {
             //如果获取信息失败则取消设置
             unset($this->infos[$file]);
         }
     }
 }
开发者ID:lunnlew,项目名称:Norma_Code,代码行数:29,代码来源:LAEGDImage.php


示例7: fixImageOrientation

 function fixImageOrientation($path)
 {
     $info = getimagesize($path);
     if ($info['mime'] != "image/jpeg") {
         return;
     }
     $exif = exif_read_data($path);
     if (exif_imagetype($path) != IMAGETYPE_JPEG) {
         return;
     }
     if (empty($exif['Orientation'])) {
         return;
     }
     $image = imagecreatefromjpeg($path);
     switch ($exif['Orientation']) {
         case 3:
             $image = imagerotate($image, 180, 0);
             break;
         case 6:
             $image = imagerotate($image, -90, 0);
             break;
         case 8:
             $image = imagerotate($image, 90, 0);
             break;
     }
     imagejpeg($image, $path);
 }
开发者ID:krombox,项目名称:motion,代码行数:27,代码来源:ImageTypeExtension.php


示例8: post

 protected function post()
 {
     $json = array();
     $userName = $this->user->getUserName();
     $tmpFileName = $this->request->files['file']['tmp_name'];
     $srcFileName = urldecode($this->request->files['file']['name']);
     $tmpfilesize = filesize($this->request->files['file']['tmp_name']);
     $vendorId = $this->user->getVP();
     //file type must be acceptable
     $imageType = exif_imagetype($this->request->files['file']['tmp_name']);
     if (IMAGETYPE_GIF != $imageType && IMAGETYPE_JPEG != $imageType && IMAGETYPE_PNG != $imageType) {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_FILE_ERROR, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_FILE_ERROR));
     }
     //file size must be >0
     if (0 >= $tmpfilesize) {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_FILE_ERROR, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_FILE_ERROR));
     }
     //append timestamp to all uploaded image filenames to ensure uniqueness
     $path_parts = pathinfo($srcFileName);
     $fileNameTimestamped = $path_parts['filename'] . "_" . time() . "." . $path_parts['extension'];
     $destination = "catalog/" . $userName . "/" . $fileNameTimestamped;
     //move tmpfile to proper vendor-specific location
     if (!rename($tmpFileName, DIR_IMAGE . $destination)) {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_FILE_ERROR, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_FILE_ERROR));
     }
     $this->load->model('catalog/vdi_vendor_profile');
     //ask model to associate image in db, providing vendor id and destination filename
     $this->model_catalog_vdi_vendor_profile->setVendorProfileImage($vendorId, $destination);
     $json['filename'] = $fileNameTimestamped;
     $this->response->setOutput($json);
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:31,代码来源:profile_image.php


示例9: type

 /**
  * get the imagetype of an image object
  * @return string imagetype XXX constant
  */
 public function type()
 {
     if ($this->exists() == false) {
         return "Unable to get file";
     }
     return exif_imagetype($this->url);
 }
开发者ID:idoqo,项目名称:yedoe,代码行数:11,代码来源:image.class.php


示例10: uploadRemoteFile

 function uploadRemoteFile($urlimage, $filename, $urlslug, $user_id = NULL)
 {
     $this->CI->output->set_header('Content-Type: application/json; charset=utf-8');
     $user_name = isset($user_id) ? username($user_id) : $this->CI->ion_auth->user()->row()->username;
     //get file info so we can check for allowed extensions
     $file_parts = pathinfo($urlimage);
     $exts = array('jpg', 'gif', 'png', 'jpeg');
     if (isset($file_parts['extension']) && in_array($file_parts['extension'], $exts)) {
         //check the exif data to ensure its a valid image type
         $image_exists = @fopen($urlimage, "r");
         if ($image_exists === false) {
             $output_array = array('validation' => 'error', 'response' => 'error', 'message' => 'Check image URL. Supplied URL does not appear to be an image.');
             $this->CI->output->set_output(json_encode($output_array));
         } else {
             fclose($image_exists);
             if (exif_imagetype($urlimage)) {
                 //send back json error for modal
                 //if folder for song does not  exist, make the folder
                 if (!file_exists(FCPATH . 'asset_uploads/' . $user_name . '/' . $urlslug)) {
                     mkdir(FCPATH . 'asset_uploads/' . $user_name . '/' . $urlslug, 0755, true);
                     file_put_contents(FCPATH . 'asset_uploads/' . $user_name . '/' . $urlslug . '/index.html', 'index.html');
                 }
                 //get the image
                 $image = file_get_contents($urlimage);
                 //save the image
                 file_put_contents(FCPATH . 'asset_uploads/' . $user_name . '/' . $urlslug . '/' . $filename . '.' . $file_parts['extension'], $image);
                 return true;
             }
         }
     } else {
         //send back json error for modal
         $output_array = array('validation' => 'error', 'response' => 'error', 'message' => 'Image filetype not supported. JPG or PNG only please!');
         $this->CI->output->set_output(json_encode($output_array));
     }
 }
开发者ID:JamesWuChina,项目名称:hhvip-ci,代码行数:35,代码来源:Images.php


示例11: getImageFromUrl

 public static function getImageFromUrl($image_url)
 {
     try {
         $mime = image_type_to_mime_type(exif_imagetype($image_url));
     } catch (Exception $e) {
         throw new MimeTypeException($e->getMessage());
     }
     //Get image based on mime and set to $im
     switch ($mime) {
         case 'image/jpeg':
             $im = imagecreatefromjpeg($image_url);
             break;
         case 'image/gif':
             $im = imagecreatefromgif($image_url);
             break;
         case 'image/png':
             $im = imagecreatefrompng($image_url);
             break;
         case 'image/wbmp':
             $im = imagecreatefromwbmp($image_url);
             break;
         default:
             throw new MimeTypeException("An image of '{$mime}' mime type is not supported.");
             break;
     }
     return $im;
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:27,代码来源:LitmusService.php


示例12: save_image

function save_image($image_file, $user_id)
{
    global $image_dir;
    if (!file_exists($image_dir . $user_id)) {
        if (mkdir($image_dir . $user_id, 0777)) {
            chmod($image_dir . $user_id, 0777);
        } else {
            echo json_encode(array("error" => "could not create user directory "));
        }
    }
    if (!isset($image_file["tmp_name"])) {
        echo json_encode(array("error" => "file not selected"));
        exit;
    } else {
        $file_path = $image_dir . $user_id . "/" . md5(uniqid(rand(), true)) . ".png";
        $temp_file = $image_file["tmp_name"];
        $save = false;
        $type = exif_imagetype($temp_file);
        if ($type == IMAGETYPE_PNG) {
            $save = move_uploaded_file($temp_file, $file_path);
        }
        if ($type == IMAGETYPE_JPEG || $type == IMAGETYPE_GIF) {
            $save = imagepng(imagecreatefromstring(file_get_contents($temp_file)), $file_path);
        }
        if (!$save) {
            echo json_encode(array("error" => "upload faild"));
            exit;
        }
    }
    return $file_path;
}
开发者ID:IshitaTakeshi,项目名称:ClothingRecommenderWeb,代码行数:31,代码来源:libs.php


示例13: uploadSlide

 function uploadSlide($file)
 {
     if (!empty($file['tmp_name'])) {
         if (is_uploaded_file($file['tmp_name'])) {
             //verify its actually an image
             if (exif_imagetype($file['tmp_name'])) {
                 $saved = move_uploaded_file($file['tmp_name'], $this->slides_fp . $file['name']);
                 if ($saved) {
                     $returndata = array();
                     $returndata['title'] = $file['name'];
                     $returndata['image'] = '/' . $this->slides_dir . $file['name'];
                     $returndata['description'] = '';
                     $returndata['link'] = '';
                     return $returndata;
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:ngardner,项目名称:BentoCMS,代码行数:27,代码来源:SlideshowModel.php


示例14: insertNewImage

 function insertNewImage($FilePath, $OriginalFileName)
 {
     $ImageType = exif_imagetype($FilePath);
     $Email = $this->Email;
     $this->initializeConnection();
     $sql = "INSERT INTO UserFiles(ImageType,FileName,Owner) OUTPUT INSERTED.FileID VALUES (?,?,?)";
     $params = array($ImageType, $OriginalFileName, $Email);
     global $conn;
     if ($conn) {
         $stmt = sqlsrv_query($conn, $sql, $params);
         if ($stmt === false) {
             $error = sqlsrv_errors();
             return false;
         } else {
             if (sqlsrv_has_rows($stmt) > 0) {
                 $FileID = '';
                 while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
                     $FileID = $row['FileID'];
                 }
                 return $this->uploadImage($FilePath, $FileID);
             } else {
                 return false;
             }
         }
     }
 }
开发者ID:GPHofficial,项目名称:urimg,代码行数:26,代码来源:fileManagement.php


示例15: get_file_info

 private function get_file_info($file)
 {
     $filesize = 0;
     $fileParts = parse_url($file);
     $path = arr::get($fileParts, 'path');
     $path = substr_replace($path, '', 0, 1);
     $path = urldecode($path);
     $pathParts = explode('/', $path);
     $name = end($pathParts);
     if (is_file(PUBLIC_ROOT . $path)) {
         $filesize = filesize(PUBLIC_ROOT . $path) / 1000;
     }
     $mbSize = $filesize / 1000;
     $type = 'KB';
     if ($mbSize > 1) {
         $filesize = $mbSize;
         $type = 'MB';
     }
     $fileType = 'file';
     try {
         $exifImageType = @exif_imagetype(PUBLIC_ROOT . $path);
         if ($exifImageType > 0 && $exifImageType < 18) {
             $fileType = 'image';
         }
     } catch (Exception $e) {
     }
     return array('type' => $type, 'size' => round($filesize, 2, PHP_ROUND_HALF_UP), 'name' => $name, 'file_type' => $fileType);
 }
开发者ID:ariol,项目名称:adminshop,代码行数:28,代码来源:Abstract.php


示例16: isImage

function isImage($tmp_name)
{
    $allowedTypes = array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF);
    $detectedType = exif_imagetype($tmp_name);
    $rs = in_array($detectedType, $allowedTypes);
    return $rs;
}
开发者ID:tuanvu5503,项目名称:thungrac.vn,代码行数:7,代码来源:Validation_Helper.php


示例17: ReSize

 /**
  *  Resize an image to the specified dimensions, placing the resulting
  *  image in the specified location.  At least one of $newWidth or
  *  $newHeight must be specified.
  *
  *  @param  string  $type       Either 'thumb' or 'disp'
  *  @param  integer $newWidth   New width, in pixels
  *  @param  integer $newHeight  New height, in pixels
  *  @return string  Blank if successful, error message otherwise.
  */
 public static function ReSize($src, $dst, $newWidth = 0, $newHeight = 0)
 {
     global $_LGLIB_CONF;
     // Calculate the new dimensions
     $A = self::reDim($src, $newWidth, $newHeight);
     if ($A === false) {
         COM_errorLog("Invalid image {$src}");
         return 'invalid image conversion';
     }
     list($sWidth, $sHeight, $dWidth, $dHeight) = $A;
     // Get the mime type for the glFusion resizing functions
     $mime_type = image_type_to_mime_type(exif_imagetype($src));
     // Returns an array, with [0] either true/false and [1]
     // containing a message.
     $result = array();
     if (function_exists(_img_resizeImage)) {
         $result = _img_resizeImage($src, $dst, $sHeight, $sWidth, $dHeight, $dWidth, $mime_type);
     } else {
         $result[0] = false;
     }
     if ($result[0] == true) {
         return '';
     } else {
         COM_errorLog("Failed to convert {$src} ({$sHeight} x {$sWidth}) to {$dst} ({$dHeight} x {$dWidth})");
         return 'invalid image conversion';
     }
 }
开发者ID:NewRoute,项目名称:lglib,代码行数:37,代码来源:image.class.php


示例18: supports

 public static function supports($path)
 {
     if (!extension_loaded('exif')) {
         throw new Exception("Cannot verify '{$path}' image type, Exif extension is not loaded");
     }
     return exif_imagetype($path) == IMAGETYPE_GIF;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:7,代码来源:GIF.php


示例19: savePhoto

 public function savePhoto()
 {
     $input = \Request::all();
     $data = explode(',', $input['image_base64']);
     $filename = $input['filename'];
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     $ext_extra_data = parse_url($ext, PHP_URL_QUERY);
     $ext = str_replace("?" . $ext_extra_data, "", $ext);
     $filename = uniqid() . "." . $ext;
     $ifp = fopen($this->save_photo_path . "/" . $filename, "wb");
     fwrite($ifp, base64_decode($data[1]));
     fclose($ifp);
     $type = exif_imagetype($this->save_photo_path . "/" . $filename);
     if (!in_array($type, $this->allow_image_types)) {
         return response(['error' => 'not_allowed'], 412);
     }
     // deactivate other photos
     $affected = UserPhoto::where('status', '=', 1)->where('user_id', \Auth::user()->id)->update(array('status' => 0));
     $userPhoto = new UserPhoto();
     $userPhoto->user_id = \Auth::user()->id;
     $userPhoto->filename = $filename;
     $userPhoto->save();
     $userPhoto->path = url("/" . $this->save_photo_folder . "/" . $userPhoto->filename);
     return $userPhoto;
 }
开发者ID:bancuadrian,项目名称:facebookphotocontest,代码行数:25,代码来源:PhotoController.php


示例20: getThumbnail

 public static function getThumbnail($url, $size = 25)
 {
     $fileName = self::getImageName($url);
     if (!empty($url)) {
         if (exif_imagetype($url) != IMAGETYPE_JPEG) {
             list($widthOrig, $heightOrig) = getimagesize($url);
             if ($heightOrig > 840) {
                 $width = ceil($widthOrig * $size / 100);
                 $height = ceil($heightOrig * $size / 100);
                 // This resamples the image
                 $imageR = \imagecreatetruecolor($width, $height);
                 $image = \imagecreatefromjpeg($url);
                 \imagecopyresampled($imageR, $image, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
                 $destinationPath = __DIR__ . self::PATH . $fileName;
                 if (!file_exists($destinationPath)) {
                     imagejpeg($imageR, $destinationPath);
                 }
                 return self::PATH_TO_HERE . self::PATH . $fileName;
             } else {
                 return $url;
             }
         } else {
             return $url;
         }
     } else {
         return $url;
     }
 }
开发者ID:javierdlahoz,项目名称:dcbia-wp,代码行数:28,代码来源:PictureHelper.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP exif_read_data函数代码示例发布时间:2022-05-15
下一篇:
PHP exibirDataMysql函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap