Gets the width and height of a draft image.

@param int $draftitemid ID of the draft image
@return array Return array of the width and height of the draft image.
359050
public function get_image_size_in_draft_area($draftitemid) {
        global $USER;
        $usercontext = context_user::instance($USER->id);
        $fs = get_file_storage();
        $draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
        if ($draftfiles) {
            foreach ($draftfiles as $file) {
                if ($file->is_directory()) {
                    continue;
                }
                // Just return the data for the first good file, there should only be one.
                $imageinfo = $file->get_imageinfo();
                $width    = $imageinfo['width'];
                $height   = $imageinfo['height'];
                return array($width, $height);
            }
        }
        return null;
    }
68494
public function getColumnWidths()
    {
        $data = ArrayList::create();
        
        $widths = $this->getColumnWidthData();
        
        foreach ($widths->getViewports() as $viewport) {
            
            if ($value = $widths->getField($viewport)) {
                
                $gutter = (int) $this->Gutter;
                
                if ($this->ColumnUnitCSS == '%') {
                    $gutter = $gutter - ($gutter * ($value / 100));
                }
                
                $data->push(
                    ArrayData::create([
                        'Unit' => $this->ColumnUnitCSS,
                        'Width' => sprintf('%F%s', $value, $this->ColumnUnitCSS),
                        'Gutter' => $gutter,
                        'Breakpoint' => $widths->getBreakpoint($viewport)
                    ])
                );
                
            }
            
        }
        
        return $data;
    }
69618
public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
	{
		$Width   = $oldWidth;  //Default, and flash require this
		$Height  = $oldHeight; //Default, and flash require this
		$oriSize = true;       //Attribute for images without conversion
		
		if ($newWidth > 0 && $newHeight > 0) 
		{
			$Width   = $newWidth;
			$Height  = $newHeight;
			$oriSize = false;
		}
		elseif ($newWidth > 0)
		{
			$Width   = $newWidth;
			$Height  = ceil($newWidth * $oldHeight / $oldWidth);
			$oriSize = false;
		}
		elseif ($newHeight > 0)
		{
			$Width   = ceil($newHeight * $oldWidth / $oldHeight);
			$Height  = $newHeight;
			$oriSize = false;
		}
		return array($Width,$Height,$oriSize);
	}
920160
public function getThumbnailUrl(string $itemId, int $size = 75):array
    {
        $parameters = $this->buildHttpQuery(
            [
                'size'     => $size,
                'redirect' => false,
            ]
        );

        return $this->get("Items({$itemId})/Thumbnail?{$parameters}");
    }
446776
public static function getCalculatedSize($width, $height, $maxWidth, $maxHeight)
    {
        $widthDiffRatio = $maxWidth / $width;
        $heightDiffRatio = $maxHeight / $height;

        if ($widthDiffRatio <= $heightDiffRatio) {
            // resize based on width
            $newWidth = $maxWidth;
            $newHeight = $height * $widthDiffRatio;
        } else {
            // resize based on height
            $newWidth = $width * $heightDiffRatio;
            $newHeight = $maxHeight;
        }

        return [
            $newWidth,
            $newHeight,
        ];
    }
1229917
public function resolution($width = null, $height = null)
    {
        return [
            'width' => $width ?: $this->widths[array_rand($this->widths)],
            'height' => $height ?: $this->heights[array_rand($this->heights)]
        ];
    }
986560
public function getWidth()
    {
      if ($this->width != null) {
        return $this->width;
      }

      list($width) = getimagesize($this->_files['tmp_name']);

      return $width;
    }
681651
public function getSize()
    {
        $command = $this->driver->factoryCommand(
            'window/' . $this->windowHandle . '/size',
            WebDriver_Command::METHOD_GET
        );
        $value = $this->driver->curl($command)['value'];
        return ['height' => $value['height'], 'width' => $value['width']];
    }
430273
public function getButtonDimensions()
    {
        // Initialise:
        
        $data = [];
        
        // Obtain Dimensions:
        
        $sizes = $this->dbObject('ButtonSize');
        
        // Iterate Size Viewports:
        
        foreach ($sizes->getViewports() as $viewport) {
            
            if ($value = $sizes->getField($viewport)) {
                $data[$viewport]['Size'] = $value;
                $data[$viewport]['Breakpoint'] = $sizes->getBreakpoint($viewport);
            }
            
        }
        
        // Obtain Icon Dimensions:
        
        $iconSizes = $this->dbObject('IconSize');
        
        // Iterate Icon Size Viewports:
        
        foreach ($iconSizes->getViewports() as $viewport) {
            
            if ($value = $iconSizes->getField($viewport)) {
                $data[$viewport]['IconSize'] = $value;
                $data[$viewport]['Breakpoint'] = $iconSizes->getBreakpoint($viewport);
            }
            
        }
        
        // Create Items List:
        
        $items = ArrayList::create();
        
        // Create Data Items:
        
        foreach ($data as $item) {
            $items->push(ArrayData::create($item));
        }
        
        // Answer Items List:
        
        return $items;
    }
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);
    }
998847
private function getThemeImageSizes()
    {
        $dataProvider = new DefaultDataProvider();
        $dataProvider->setBaseConfig(['source' => 'tl_image_size']);

        $config = $dataProvider->getEmptyConfig();
        $config->setFields(['id', 'name', 'width', 'height']);
        $config->setSorting(['pid', 'name']);

        $collection = $dataProvider->fetchAll($config);
        if (!$collection->count()) {
            return [];
        }

        $sizes = [];
        foreach ($collection as $model) {
            $sizes[$model->getProperty('id')] = sprintf(
                '%s (%sx%s)',
                $model->getProperty('name'),
                $model->getProperty('width'),
                $model->getProperty('height')
            );
        }

        return $sizes;
    }
67966
protected function get_draft_files($elname) {
        global $USER;

        if (!$this->is_submitted()) {
            return false;
        }

        $element = $this->_form->getElement($elname);

        if ($element instanceof MoodleQuickForm_filepicker || $element instanceof MoodleQuickForm_filemanager) {
            $values = $this->_form->exportValues($elname);
            if (empty($values[$elname])) {
                return false;
            }
            $draftid = $values[$elname];
            $fs = get_file_storage();
            $context = context_user::instance($USER->id);
            if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
                return null;
            }
            return $files;
        }
        return null;
    }
1017066
private function sortDraftCollection(array $drafts)
    {
        $sortedDrafts = [];
        $filteredDrafts = [];

        foreach ($drafts as $draft) {
            if (null === $draft->getContent()) {
                continue;
            }

            $sortedDrafts[$draft->getContent()->getUid()] = [$draft->getContent()->getUid() => $draft];
        }

        foreach ($drafts as $draft) {
            foreach ($draft->getContent()->getData() as $key => $element) {
                if (
                    !is_int($key)
                    && $element instanceof AbstractClassContent
                    && in_array($element->getUid(), array_keys($sortedDrafts))
                ) {
                    $elementUid = $element->getUid();
                    $sortedDrafts[$draft->getContent()->getUid()][$key] = $sortedDrafts[$elementUid][$elementUid];
                }
            }
        }

        foreach ($sortedDrafts as $key => $data) {
            foreach ($data as $elementName => $draft) {
                if ($key === $elementName) {
                    continue;
                }

                if (isset($sortedDrafts[$draft->getContent()->getUid()])) {
                    $sortedDrafts[$key][$elementName] = &$sortedDrafts[$draft->getContent()->getUid()];
                    $filteredDrafts[$draft->getContent()->getUid()] = false;
                }
            }
        }

        return array_filter(array_merge($sortedDrafts, $filteredDrafts));
    }
731427
protected function calcImageSize($imageData, $maxWidth, $maxHeight)
    {
        $pdf = $this->getPdf();

        list($width, $height) = getimagesizefromstring($imageData);
        $width = $pdf->pixelsToUnits($width);
        $height = $pdf->pixelsToUnits($height);

        list($newWidth, $newHeight) = ImageResize::getCalculatedSize($width, $height, $maxWidth, $maxHeight);

        return [
            $newWidth,
            $newHeight,
        ];
    }
543191
public function getExpectedSize($round = true)
	{
		if (empty($this->sourceFilename)) {
			throw new ImageProcessorException('Source image is not set');
		}
		if (empty($this->targetWidth) || ($this->targetWidth <= 0)) {
			throw new ImageProcessorException('Target width is not set or is invalid');
		}
		if (empty($this->targetHeight) || ($this->targetHeight <= 0)) {
			throw new ImageProcessorException('Target height is not set or is invalid');
		}

		$imageInfo = $this->getImageInfo($this->sourceFilename);

		$wRatio = max($imageInfo->getWidth() / $this->targetWidth, 1);
		$hRatio = max($imageInfo->getHeight() / $this->targetHeight, 1);

		if ( ! $this->cropMode) {
			$wRatio = $hRatio = max($wRatio, $hRatio);
		}

		$dimensions = array(
			'width' => $imageInfo->getWidth() / $wRatio,
			'height' => $imageInfo->getHeight() / $hRatio,
		);

		if ($round) {
			$dimensions = array_map('round', $dimensions);
		}

		return $dimensions;
	}
920886
protected function getDimensions($newWidth, $newHeight)
    {
        $usedRatio = $widthRatio = $this->width / $newWidth;
        $heightRatio = $this->height / $newHeight;

        if ($heightRatio < $widthRatio) {
            $usedRatio = $heightRatio;
        }

        $height = $this->height / $usedRatio;
        $width = $this->width / $usedRatio;

        return [$width, $height];
    }
115355
static public function getSize( $force = FALSE ){
/*		preg_match_all("/rows.([0-9]+);.columns.([0-9]+);/", strtolower(exec('stty -a |grep columns')), $output);
		if(sizeof($output) == 3) {
			self::$width	= $output[2][0];
			self::$height	= $output[1][0];
		}*/
		return (object) array(
			'colors'	=> self::getColors(),
			'height'	=> self::getHeight(),
			'width'		=> self::getWidth(),
		);
	}