Add ability to do either height or width or both
This commit is contained in:
parent
34c2902570
commit
6da8da9d8d
|
@ -26,10 +26,10 @@
|
||||||
// Omitted or 100 = no scaling done, image passed through directly
|
// Omitted or 100 = no scaling done, image passed through directly
|
||||||
// Scaling will increase response time slightly
|
// Scaling will increase response time slightly
|
||||||
//
|
//
|
||||||
// width and height are optional, but if one is passed both should be passed (or they will be ignored)
|
// width and height are each optional, ideally supply both, but if only one is supplied the other is calculated
|
||||||
// Pixel dimension to returned, scaling up or down
|
// These are in pixels
|
||||||
//
|
//
|
||||||
// If both scale and width & height are specified, scale is ignored
|
// If both scale and either width or height are specified, scale is ignored
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canView( 'Events' ) )
|
if ( !canView( 'Events' ) )
|
||||||
|
@ -95,18 +95,26 @@ if( !empty($_REQUEST['height']) )
|
||||||
if ( $errorText )
|
if ( $errorText )
|
||||||
Error( $errorText );
|
Error( $errorText );
|
||||||
else
|
else
|
||||||
if($scale==100 && ($width==0 || $height==0) )
|
if( $scale==100 && $width==0 && $height==0 )
|
||||||
readfile( ZM_DIR_EVENTS.'/'.$path );
|
readfile( ZM_DIR_EVENTS.'/'.$path );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$i = imagecreatefromjpeg ( ZM_DIR_EVENTS.'/'.$path );
|
$i = imagecreatefromjpeg ( ZM_DIR_EVENTS.'/'.$path );
|
||||||
$oldWidth=imagesx($i);
|
$oldWidth=imagesx($i);
|
||||||
$oldHeight=imagesy($i);
|
$oldHeight=imagesy($i);
|
||||||
if($width==0 || $height==0) // default to scale if either height or width is missing
|
if($width==0 && $height==0)
|
||||||
{
|
{
|
||||||
$width=$oldWidth * $scale / 100.0;
|
$width=$oldWidth * $scale / 100.0;
|
||||||
$height=$oldHeight * $scale / 100.0;
|
$height=$oldHeight * $scale / 100.0;
|
||||||
}
|
}
|
||||||
|
elseif ($width==0 && $height!=0)
|
||||||
|
{
|
||||||
|
$width = ($oldWidth / $OldHeight) * $height;
|
||||||
|
}
|
||||||
|
elseif ($width!=0 && $height==0)
|
||||||
|
{
|
||||||
|
$height = ($oldHeight / $oldWidth) * $width;
|
||||||
|
}
|
||||||
if($width==$oldWidth && $height==$oldHeight) // See if we really need to scale
|
if($width==$oldWidth && $height==$oldHeight) // See if we really need to scale
|
||||||
{
|
{
|
||||||
imagejpg($i);
|
imagejpg($i);
|
||||||
|
|
Loading…
Reference in New Issue