You are here: Re: calculate image height or width « PHP Programming Language « IT news, forums, messages
Re: calculate image height or width

Posted by comp.lang.php on 04/11/06 02:42

Never mind, I got it on my own:

/**
* Perform calculation solely upon re-entered width and height if a
calculation percentage was not entered nor chosen. Can be called
statically
*
* @access protected
* @param int $width (reference)
* @param int $height (reference)
* @param int $origWidth
* @param int $origHeight
* @return array $dimArray Array consisting of recalculated width and
height
*/
function &calculate_width_and_height(&$width, &$height, $origWidth,
$origHeight) {
if ((int)$origWidth === 0 || (int)$origHeight === 0) return
array($width, $height); // TO AVOID DIVISION BY ZERO
if ((int)$origWidth !== (int)$width && (int)$origHeight !==
(int)$height) return array($width, $height); // NO NEED TO CALCULATE
SINCE CHANGING ALL DIMENSIONS
if ((int)$origWidth !== (int)$width) $height = $width * ($origHeight
/ $origWidth);
if ((int)$origHeight !== (int)$height) $width = $height * ($origWidth
/ $origHeight);
return array(floor($width), floor($height));
}

Phil

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация