Skip to content

Instantly share code, notes, and snippets.

@dzarezenko
Created December 15, 2009 22:19
Show Gist options
  • Save dzarezenko/257362 to your computer and use it in GitHub Desktop.
Save dzarezenko/257362 to your computer and use it in GitHub Desktop.
<?php
if (!empty($resize)) {
if(preg_match("/[^0-9\.]/",$resize)) { // Queremos solo numeros!
$errormsg = JUST_NUMBERS;
$titulo = UPLOADED_BUT_NOT_RESIZED.ESP_TITULO;
$spit = true;
$red = 2;
} else {
if ($dimension == "large_side") {
$dimension = "width";
if ($ancho < $alto) {
$dimension = "height";
}
}
if ($dimension == "width") {
if ($allow_over_resize==false && $resize > $ancho) {
$errormsg = OVER_RESIZE_ERROR.' ('.$ancho.'px)';
$titulo = UPLOADED_BUT_NOT_RESIZED.ESP_TITULO;
$spit = true;
$red = 2;
} else {
if ($resize<=$higres && $resize>=$lowres) {
$new_alto = round($resize*$alto/$ancho);
// Seteamos el nuevo alto y ancho
unset($ancho);
unset($alto);
$ancho = $resize;
$alto = $new_alto;
$red = 1;
} else {
$errormsg = RESIZE_LIMITS.' '.$lowres.' '.ANDTEXT.' '.$higres.' (pixels)';
$titulo = UPLOADED_BUT_NOT_RESIZED.ESP_TITULO;
$spit = true;
$red = 2;
}
}
} elseif ($dimension == "height") {
if ($allow_over_resize==false && $resize > $alto) {
$errormsg = OVER_RESIZE_ERROR.' ('.$ancho.'px)';
$titulo = UPLOADED_BUT_NOT_RESIZED.ESP_TITULO;
$spit = true;
$red = 2;
} else {
if ($resize<=$higres && $resize>=$lowres) {
$new_ancho = round($resize*$ancho/$alto);
// Seteamos el nuevo alto y ancho
unset($ancho);
unset($alto);
$ancho = $new_ancho;
$alto = $resize;
$red = 1;
} else {
$errormsg = RESIZE_LIMITS.' '.$lowres.' '.ANDTEXT.' '.$higres.' (pixels)';
$titulo = UPLOADED_BUT_NOT_RESIZED.ESP_TITULO;
$spit = true;
$red = 2;
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment