zapWidth and zapHeight are now in conf.php (#21)

This commit is contained in:
Fabian de Boer 2026-07-19 22:47:19 +02:00
commit e96b8e5563
4 changed files with 9 additions and 14 deletions

View file

@ -6,6 +6,9 @@
define('MAX_WORDS', 4);
define('MAX_ZAPS', 9);
define('ZAP_DEFAULT_WIDTH', 1067);
define('ZAP_DEFAULT_HEIGHT', 600);
define('ZAP_CURL_TIMEOUT', 12);
define('ZAP_IMG_TYPE', 'jpg');
define('ZAP_CANVAS_NAME', 'collage');

View file

@ -3,9 +3,6 @@
* Image Input Output Tools
*/
class ImgIOTools {
public static $maxScreenWidth = 1067; //screen dimensions
public static $maxScreenHeight = 600;
/**
* Flushes image to screen
@ -13,9 +10,9 @@ class ImgIOTools {
* @return void
*/
public static function onScreen(Imagick $img) {
$img->scaleImage(self::$maxScreenWidth, self::$maxScreenHeight, true);
$img->scaleImage(ZAP_DEFAULT_WIDTH, ZAP_DEFAULT_HEIGHT, true);
//$img = self::scaleByLength($img, $this->maxScreenWidth, $this->maxScreenHeight);
//$img = self::scaleByLength($img, ZAP_DEFAULT_WIDTH, ZAP_DEFAULT_HEIGHT);
header('Content-type: image/' . ZAP_IMG_TYPE);
echo $img->getImageBlob();
}
@ -46,5 +43,4 @@ class ImgIOTools {
$path = $folder . $filename . '.' . ZAP_IMG_TYPE;
return $img->writeImage($path);
}
}
?>
}

View file

@ -3,10 +3,6 @@
* Library of tool functions to manipulate an image
*/
class ImgTools {
public static $maxScreenWidth = 1067; //screen dimensions
public static $maxScreenHeight = 600;
public static $minFuzzFactor = 0.08; //minimal factor for $fuzz
public static $maxFuzzFactor = 0.64; //maximal factor for $fuzz
@ -161,7 +157,7 @@ class ImgTools {
public static function scaleByLength(Imagick $img, $maxW, $maxH) {
$width = $img->getImageWidth();
$height = $img->getImageHeight();
if(($width <= self::$maxScreenWidth) && ($height <= self::$maxScreenHeight)) {
if(($width <= ZAP_DEFAULT_WIDTH) && ($height <= ZAP_DEFAULT_HEIGHT)) {
return $img;
} else {
if ($width >= $height) { //horizontal image

View file

@ -32,10 +32,10 @@
</select>
</div>
<div class="inp">
width <input type="text" name="width" id="width" size="5" maxlength="4" value="1067"> px
width <input type="text" name="width" id="width" size="5" maxlength="4" value="<?= ZAP_DEFAULT_WIDTH ?>"> px
</div>
<div class="inp">
height <input type="text" name="height" id="height" size="5" maxlength="4" value="600"> px
height <input type="text" name="height" id="height" size="5" maxlength="4" value="<?= ZAP_DEFAULT_HEIGHT ?>"> px
</div>
<div class="inp">
<input type="button" class="btn" onclick="form1Submit()" value="Go &amp; Generate Some Zaps">