-
- function CheckImageSize($ImageFileName,$LimitSize)
- {
- $size=GetImageSize($ImageFileName);
- if ($size[0]>$LimitSize[0]||$size[1]> $LimitSize[1]){
- echo 'Sorry, the size of the image you want to upload is too large';
- return false;
- }
- return true;
- }
Copy code
Note, the return of the GetImageSize() function Value is an array.
For example:
-
- $arr = getimagesize("1.jpg");
- /*
- * Here $arr is an array type
- * $arr[0] is the width of the image
- * $arr[1] is the image The height
- * $arr[2] is the format of the image, including jpg, gif and png, etc.
- * $arr[3] is the width and height of the image, the content is width="xxx" height="yyy" */
Copy code
Example 3, getimagesize function usage.
-
- $size = getimagesize($filename);
- $fp=fopen($filename, "rb");
- if ($size && $fp) { // bbs.it- home.org
- header("Content-type: {$size['mime']}");
- fpassthru($fp);
- exit;
- } else {
- // error
- }
- ?>
Copy the code
Example 4, getimagesize function usage (example from php manual).
-
- $size = getimagesize("testimg.jpg", &$info);
- if (isset($info["APP13"])) {
- $iptc = iptcparse($info ["APP13"]);
- var_dump($iptc);
- }
- ?>
Copy code
|