Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: zheev
- * Date: 26.01.18
- * Time: 0:49
- */
- echo '<form action="/" enctype="multipart/form-data" method="post">
- <input type="file" name="foto" />
- <input type="submit" name="submit" />
- </form>';
- $mime = [
- 'image/png',
- 'image/jpeg',
- 'image/jpeg',
- 'image/jpg',
- 'image/gif',
- 'image/bmp',
- 'image/vnd.microsoft.icon',
- 'image/tiff',
- 'image/tiff',
- 'image/svg+xml',
- 'image/svg+xml',
- ];
- if($_POST['submit'])
- {
- $sum = 0;
- $name = $_FILES['foto']['tmp_name'];
- $sizes = getimagesize($name);
- if(in_array($sizes['mime'], $mime))
- {
- $type = explode('/', $sizes['mime']);
- if($type[1] == 'png')
- {
- $photo = imagecreatefrompng($name);
- }elseif($type[1] == 'jpeg')
- {
- $photo = imagecreatefromjpeg($name);
- }
- for($w = 0; $w <= $sizes[0]; $w++)
- {
- for($h=0; $h <= $sizes[1]; $h++)
- {
- $color = imagecolorat($photo, $w, $h);
- // получаем цвета
- $arr_col = imagecolorsforindex($photo, $color);
- if($arr_col['red'] == 255 and $arr_col['green'] == 255 and $arr_col['blue'] == 255)
- {
- $sum = $sum + 1;
- }
- }
- }
- echo $sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement