Gets the size of an image

@param mixed Imagine Image object or string of a file name
@return array first value is width, second height
@see Imagine\Image\ImageInterface::getSize()
5863
public function getImageSize($Image = null) {
		$Image = $this->_getImage($Image);
		$BoxInterface = $Image->getSize($Image);
		return [
			$BoxInterface->getWidth(),
			$BoxInterface->getHeight(),
			'x' => $BoxInterface->getWidth(),
			'y' => $BoxInterface->getHeight()
		];
	}
633951
function size($filename)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        $filename = $this->_realpath($filename);
        if ($filename === false) {
            return false;
        }

        return $this->_size($filename);
    }
206968
public function fileSize($size) {
        $this->p1 = $size;
        $this->check_role = 'fileSize';
        if ($this->value instanceof File) {
            $result = filesize($this->value->path_tmp) <= $this->strToSize($size) ;
        } else {
            $result = filesize($this->value) <= $this->strToSize($size) ;
        }
        $this->checkResult($result);
        return $this;
    }
143381
public function getImageSize(PersistentResource $resource)
    {
        $cacheIdentifier = $resource->getCacheEntryIdentifier();

        $imageSize = $this->imageSizeCache->get($cacheIdentifier);
        if ($imageSize !== false) {
            return $imageSize;
        }

        // TODO: Special handling for SVG should be refactored at a later point.
        if ($resource->getMediaType() === 'image/svg+xml') {
            $imageSize = ['width' => null, 'height' => null];
        } else {
            try {
                $imagineImage = $this->imagineService->read($resource->getStream());
                $sizeBox = $imagineImage->getSize();
                $imageSize = ['width' => $sizeBox->getWidth(), 'height' => $sizeBox->getHeight()];
            } catch (\Exception $e) {
                throw new ImageFileException(sprintf('The given resource was not an image file your choosen driver can open. The original error was: %s', $e->getMessage()), 1336662898);
            }
        }

        $this->imageSizeCache->set($cacheIdentifier, $imageSize);
        return $imageSize;
    }
394365
private function getImageRtfWidth()
    {
        if ($this->_width > 0) {
            return PHPRtfLite_Unit::getUnitInTwips($this->_width);
        }

        $imageWidth = $this->_imageWidth ? $this->_imageWidth : 100;
        if ($this->_height > 0) {
            $imageHeight = $this->_imageHeight ? $this->_imageHeight : 100;
            $width = ($imageWidth / $imageHeight) * $this->_height;
            return PHPRtfLite_Unit::getUnitInTwips($width);
        }

        return PHPRtfLite_Unit::getPointsInTwips($imageWidth);
    }
462743
public function getSize()
    {
        $size = $this->image->getSize();

        return $this->arr([
                              'width'  => $size->getWidth(),
                              'height' => $size->getHeight()
                          ]
        );
    }
578818
public static function get_image_size($size)
    {
        $sizes = static::get_image_sizes();

        if (\is_string($size) && isset($sizes[ $size ])) {
            return $sizes[ $size ];
        }

        return false;
    }
934442
public function getSize()
    {
        $size = $this->getParameters()->get('size');
        if (\is_numeric($size)) {
            $size = (int) $size;
        }

        return $size;
    }
585116
public function size(String $fileName) : stdClass
    {
        if( $this->mime->type($fileName, 0) === 'image' )
        {
            $data = getimagesize($fileName);
        }
        elseif( is_string($fileName) )
        {
            $data = getimagesizefromstring($fileName);
        }
        else
        {
            throw new InvalidArgumentException(NULL, '[file]');
        }

        return (object)
        [
            'width'     => $data[0],
            'height'    => $data[1],
            'extension' => $this->extension($data[2]),
            'img'       => $data[3],
            'bits'      => $data['bits'],
            'mime'      => $data['mime']
        ];
    }
565026
public function findImageSize($sizeName)
	{
		if ($this->imageSizes->containsKey($sizeName)) {
			return $this->imageSizes->get($sizeName);
		} else {
			return null;
		}
	}
129067
public static function getimagesize(string $file) {
		if (! $file || ! \is_file($file)) {
			return false;
		}

		// Do a quick MIME check to make sure this is something image-
		// like.
		$finfo = mime::finfo($file);
		$mime = $finfo['mime'];

		if (0 !== \strpos($mime, 'image/')) {
			return false;
		}

		// If this is an SVG, let's use our own function.
		if ('image/svg+xml' === $mime) {
			if (false === ($tmp = static::svg_dimensions($file))) {
				return false;
			}

			// Fake it till you make it.
			return array(
				$tmp['width'],
				$tmp['height'],
				-1,
				\sprintf(
					'width="%d" height="%d"',
					$tmp['width'],
					$tmp['height']
				),
				'mime'=>'image/svg+xml',
			);
		}

		// Try getimagesize() first, just in case.
		if (false !== ($info = @\getimagesize($file))) {
			return $info;
		}

		// Manually parse WebP.
		if (
			('image/webp' === $mime) &&
			($handle = @\fopen($file, 'rb'))
		) {
			// The magic (and dimensions) are in the first 40 bytes.
			$magic = @\fread($handle, 40);
			\fclose($handle);

			// We should have the number of bytes we asked for.
			if (\strlen($magic) < 40) {
				return false;
			}

			$width = $height = false;

			// There are three types of WebP. Haha.
			switch (\substr($magic, 12, 4)) {
				// Lossy WebP.
				case 'VP8 ':
					$parts = \unpack('v2', \substr($magic, 26, 4));
					$width = (int) ($parts[1] & 0x3FFF);
					$height = (int) ($parts[2] & 0x3FFF);
					break;
				// Lossless WebP.
				case 'VP8L':
					$parts = \unpack('C4', \substr($magic, 21, 4));
					$width = (int) ($parts[1] | (($parts[2] & 0x3F) << 8)) + 1;
					$height = (int) ((($parts[2] & 0xC0) >> 6) | ($parts[3] << 2) | (($parts[4] & 0x03) << 10)) + 1;
					break;
				// Animated/Alpha WebP.
				case 'VP8X':
					// Padd 24-bit int.
					$width = \unpack('V', \substr($magic, 24, 3) . "\x00");
					$width = (int) ($width[1] & 0xFFFFFF) + 1;

					// Pad 24-bit int.
					$height = \unpack('V', \substr($magic, 27, 3) . "\x00");
					$height = (int) ($height[1] & 0xFFFFFF) + 1;
					break;
			}

			if ($width && $height) {
				return array(
					$width,
					$height,
					\IMAGETYPE_WEBP,
					\sprintf(
						'width="%d" height="%d"',
						$width,
						$height
					),
					'mime'=>'image/webp',
				);
			}
		}

		// No dice.
		return false;
	}
1064231
private function _getProjectionSize() {
        $sourceWidth = $this->_params['sourceWidth'];
        $sourceHeight = $this->_params['sourceHeight'];
        $sourceRatio = $sourceWidth / $sourceHeight;

        $canvasWidth = $this->_params['w'];
        $canvasHeight = $this->_params['h'];
        $canvasRatio = $canvasWidth / $canvasHeight;


        //  the image is not allowed to be cut off in any dimension
        if ($sourceRatio < $canvasRatio) {
            //  source is less landscape-like than canvas
            $leadDimension = !$this->_params['crop'] ?
                'Height' : 'Width';
        } else {
            //  source is more landscape-like than canvas
            $leadDimension = !$this->_params['crop'] ?
                'Width' : 'Height';
        }

        if (!$this->_params['grow']
            && ${'source' . $leadDimension} < ${'canvas' . $leadDimension}
        ) {
            ${'projection' . $leadDimension} = ${'source' . $leadDimension};
        } else {
            ${'projection' . $leadDimension} = ${'canvas' . $leadDimension};
        }

        if (isset($projectionWidth)) {
            $projectionHeight = $projectionWidth / $sourceRatio;
        } elseif (isset($projectionHeight)) {
            $projectionWidth = $projectionHeight * $sourceRatio;
        }

        return array(round($projectionWidth), round($projectionHeight));
    }
1212822
public static function getImageSize($filename) {
		$result = false;
		ob_start();

		if (strpos($filename, '://') !== false && function_exists('fopen') && ini_get('allow_url_fopen')) {
			$stream = fopen($filename, 'r');

			$rawdata = stream_get_contents($stream, 24);
			if($rawdata) {
				$type = null;
				/**
				 * check for gif
				 */
				if (strlen($rawdata) >= 10 && strpos($rawdata, 'GIF89a') === 0 || strpos($rawdata, 'GIF87a') === 0) {
					$type = 'gif';
				}
				/**
				 * check for png
				 */
				if (!$type && strlen($rawdata) >= 24) {
					$head = unpack('C8', $rawdata);
					$png = array(1 => 137, 2 => 80, 3 => 78, 4 => 71, 5 => 13, 6 => 10, 7 => 26, 8 => 10);
					if ($head === $png) {
						$type = 'png';
					}
				}
				/**
				 * check for jpg
				 */
				if (!$type) {
					$soi = unpack('nmagic/nmarker', $rawdata);
					if ($soi['magic'] == 0xFFD8) {
						$type = 'jpg';
					}
				}
				if (!$type) {
					if ( substr($rawdata, 0, 2) == 'BM' ) {
						$type = 'bmp';
					}
				}
				switch($type) {
					case 'gif':
						$data = unpack('c10', $rawdata);

						$result = new stdClass;
						$result->width = $data[8]*256 + $data[7];
						$result->height = $data[10]*256 + $data[9];
						break;
					case 'png':
						$type = substr($rawdata, 12, 4);
						if ($type === 'IHDR') {
							$info = unpack('Nwidth/Nheight', substr($rawdata, 16, 8));

							$result = new stdClass;
							$result->width = $info['width'];
							$result->height = $info['height'];
						}
						break;
					case 'bmp':
						$header = unpack('H*', $rawdata);
						// Process the header
						// Structure: http://www.fastgraph.com/help/bmp_header_format.html
						// Cut it in parts of 2 bytes
						$header = str_split($header[1], 2);
						$result = new stdClass;
						$result->width = hexdec($header[19] . $header[18]);
						$result->height = hexdec($header[23] . $header[22]);
						break;
					case 'jpg':
						$pos = 0;
						while(1) {
							$pos += 2;
							$data = substr($rawdata, $pos, 9);
							if (strlen($data) < 4) {
								break;
							}
							$info = unpack('nmarker/nlength', $data);
							if ($info['marker'] == 0xFFC0) {
								if (strlen($data) >= 9) {
									$info = unpack('nmarker/nlength/Cprecision/nheight/nwidth', $data);

									$result = new stdClass;
									$result->width = $info['width'];
									$result->height = $info['height'];
								}
								break;
							} else {
								$pos += $info['length'];
								if (strlen($rawdata) < $pos+9) {
									$rawdata .= stream_get_contents($stream, $info['length']+9);
								}
							}
						}
						break;
					default:
						/**
						 * Fallback to original getimagesize this may be slower than the original but safer.
						 */
						$rawdata .= stream_get_contents($stream);
						$temp = tmpfile();
						fwrite($temp, $rawdata);
						$meta_data = stream_get_meta_data($temp);

						$info = getimagesize($meta_data['uri']);

						if ($info) {
							$result = new stdClass;
							$result->width = $info[0];
							$result->height = $info[1];
						}
						fclose($temp);
						break;
				}
			}
			fclose($stream);
		}
		if (!$result) {
			$info = getimagesize($filename);

			if ($info) {
				$result = new stdClass;
				$result->width = $info[0];
				$result->height = $info[1];
			}
		}
		ob_end_clean();
		return $result;
	}
398632
public function getMetaImageResizeWidth($width = null)
    {
        if ($width) {
            return $width;
        }
        
        if ($width = $this->owner->ImageMetaResizeWidth) {
            return $width;
        }
        
        return $this->owner->getFieldFromParent('DefaultImageResizeWidth');
    }
696460
protected function getByteSize($size)
    {
        if (! preg_match('/(\d+)\s*([tgkmbi]{1,3})/i', $size, $result)) {
            return $size;
        }

        $mapping = $this->mapping[strtolower($result[2])];
        return pow($mapping[0], $mapping[1]) * $result[1];
    }
1248153
public function getImageSizeInBox(array $imageSize, array $boxSize)
    {
        list($imageWidth, $imageHeight) = $imageSize;
        list($boxWidth, $boxHeight) = $boxSize;

        if (($imageWidth <= $boxWidth) && ($imageHeight <= $boxHeight)) {
            return $imageSize;
        }

        $resizeRatio = min($boxWidth / $imageWidth, $boxHeight / $imageHeight);

        $imageWidth = ceil($imageWidth * $resizeRatio);

        if ($imageWidth > $boxWidth) {
            $imageWidth = $boxWidth;
        }

        $imageHeight = ceil($imageHeight * $resizeRatio);

        if ($imageHeight > $boxHeight) {
            $imageHeight = $boxHeight;
        }

        return array($imageWidth, $imageHeight);
    }
1014826
public function getSize()
    {
        if ($this->size === null && $this->storage->supportsSize()) {
            $this->size = $this->storage->getSize($this->key);
        }

        return $this->size;
    }