Webgui: ongoing development
This commit is contained in:
+22
-5
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/******************************************************************************
|
||||
* YMS - Yacht Management Software
|
||||
* Copyright (C) 2024 Thomas Hooge
|
||||
* Copyright (C) 2024-2026 Thomas Hooge
|
||||
*
|
||||
* SPDX-License-Identifier: WTFPL
|
||||
******************************************************************************/
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
require 'globals.inc';
|
||||
require 'lib/gpc.inc';
|
||||
require 'lib/fileutils.inc';
|
||||
|
||||
$docid = gpc_get_int($_GET, 'id');
|
||||
@@ -75,7 +76,7 @@ if (isset($thumb)) {
|
||||
// scale down
|
||||
if ($doc->mimetype == 'image/jpeg') {
|
||||
$orig = imagecreatefromjpeg($file);
|
||||
$scaled = imagescale($orig, $width * $factor, $height * $factor, IMG_BICUBIC);
|
||||
$scaled = imagescale($orig, (int)($width * $factor), (int)($height * $factor), IMG_BICUBIC);
|
||||
imagejpeg($scaled, $thumbpath, 85);
|
||||
$file = $thumbpath;
|
||||
$filename = $thumbname;
|
||||
@@ -114,10 +115,26 @@ if (file_exists($file)) {
|
||||
} else {
|
||||
// dynamically create error image
|
||||
header("Content-Type: image/png");
|
||||
$im = @imagecreate(110, 20) or die(_("Cannot initialize new GD image stream"));
|
||||
$bgcolor = imagecolorallocate($im, 0, 0, 0);
|
||||
$im = @imagecreate(240, 120) or die(_('Cannot initialize new GD image stream'));
|
||||
$bgcolor = imagecolorallocate($im, 250, 250, 250);
|
||||
$txcolor = imagecolorallocate($im, 233, 14, 91);
|
||||
imagestring($im, 1, 5, 5, "Resource not found!", $txcolor);
|
||||
$border = imagecolorallocate($im, 180, 180, 180);
|
||||
|
||||
$text = _('Resource not found!');
|
||||
$font = '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf';
|
||||
$size = 12;
|
||||
|
||||
$bbox = imagettfbbox($size, 0, $font, $text);
|
||||
$textWidth = $bbox[2] - $bbox[0];
|
||||
$textHeight = $bbox[1] - $bbox[7];
|
||||
|
||||
$x = (240 - $textWidth) / 2;
|
||||
$y = (120 + $textHeight) / 2;
|
||||
imagettftext($im, $size, 0, $x, $y, $txcolor, $font, $text);
|
||||
|
||||
imagerectangle($im, 0, 0, 239, 119, $border);
|
||||
|
||||
// imagestring($im, 1, 5, 5, _('Resource not found!'), $txcolor);
|
||||
imagepng($im);
|
||||
imagedestroy($im);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user