У меня есть изображение, загруженное HTML -формой. После проверки действительного изображения он сохраняется в папке TMP -. Позже я хочу переместить файл из папки TMP - в папку «Окончательная загрузка». Для этого я написал следующую функцию. < /P>
// 1. image was uploaded via html form to the folder "images/tmp/" with validation checks for image format
// 2. show image from the "images/tmp/" folder on a summary page next to other form input data to the user
// 3. after clicking "save changes" on the summary page the following function is called
// 3.1 check if image size is big depending on $image_resolution calculated by getimagesize() function
// 3.1.1 if image is bigger than $MAX_IMAGE_RESOLUTION --> resize it down to a width of 1600px and safe to "images/uploads" as .webp file
// 3.1.2 if image is smaller than $MAX_IMAGE_RESOLUTION --> just copy the file from "images/tmp/" to "images/uploads" as .webp file
function move_img_to_upl ($tmp_file, $upl_file, $field_name) {
global $UPPER_DIR; // "../"
global $UPL_DIR_IMG; // "images/uploads/
global $TMP_DIR_IMG; // "images/tmp/"
global $MAX_IMAGE_RESOLUTION; // 1707200
global $MAX_IMAGE_WIDTH; // 1600
global $IMAGE_QUALITY; // 90
$separator = "_";
$tempdir = $UPPER_DIR.$TMP_DIR_IMG;
$uploaddir = $UPPER_DIR.$UPL_DIR_IMG;
$image_size = getimagesize($tempdir.$tmp_file);
$old_width = $image_size[0];
$old_height = $image_size[1];
$image_resolution = $old_width * $old_height;
// if image resolution > 1707200 px --> resize to a max width of 1600 px
if ($image_resolution > $MAX_IMAGE_RESOLUTION) {
$image_ratio = $old_height / $old_width;
$new_height = round($MAX_IMAGE_WIDTH * $image_ratio);
$new_width = $MAX_IMAGE_WIDTH;
$image_name = pathinfo($tempdir.$tmp_file, PATHINFO_FILENAME);
$destination = $uploaddir.$image_name.".webp";
$image_old_mime_type = mime_content_type($tempdir.$tmp_file);
if ($image_old_mime_type === "image/png") {
$image_old = imagecreatefrompng($tempdir.$tmp_file);
}
elseif ($image_old_mime_type === "image/jpeg") {
$image_old = imagecreatefromjpeg($tempdir.$tmp_file);
}
elseif ($image_old_mime_type === "image/jpg") {
$image_old = imagecreatefromjpeg($tempdir.$tmp_file);
}
elseif ($image_old_mime_type === "image/webp") {
$image_old = imagecreatefromwebp($tempdir.$tmp_file);
}
$image_new = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_new, $image_old, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);
imagewebp($image_new, $destination, $IMAGE_QUALITY);
unlink($tempdir.$tmp_file);
imagedestroy($image_old);
imagedestroy($image_new);
}
// if image resoultion just move the file from the tmp directory to the uploads directory
else {
rename($tempdir.$tmp_file, $uploaddir.$upl_file);
}
}
Только когда загружается большой .heic -файл , сценарий, кажется, поворачивает изображение BEI -90Deg. Когда небольшой файл. /> Я также проверил игру Arround с переменными $ max_image_resolution и $ max_image_width. Но это, кажется, зависит только от размера изображения.
У меня есть изображение, загруженное HTML -формой. После проверки действительного изображения он сохраняется в папке TMP -. Позже я хочу переместить файл из папки TMP - в папку «Окончательная загрузка». Для этого я написал следующую функцию. < /P> [code]// 1. image was uploaded via html form to the folder "images/tmp/" with validation checks for image format // 2. show image from the "images/tmp/" folder on a summary page next to other form input data to the user // 3. after clicking "save changes" on the summary page the following function is called // 3.1 check if image size is big depending on $image_resolution calculated by getimagesize() function // 3.1.1 if image is bigger than $MAX_IMAGE_RESOLUTION --> resize it down to a width of 1600px and safe to "images/uploads" as .webp file // 3.1.2 if image is smaller than $MAX_IMAGE_RESOLUTION --> just copy the file from "images/tmp/" to "images/uploads" as .webp file
function move_img_to_upl ($tmp_file, $upl_file, $field_name) {
global $UPPER_DIR; // "../" global $UPL_DIR_IMG; // "images/uploads/ global $TMP_DIR_IMG; // "images/tmp/" global $MAX_IMAGE_RESOLUTION; // 1707200 global $MAX_IMAGE_WIDTH; // 1600 global $IMAGE_QUALITY; // 90 $separator = "_";
} // if image resoultion just move the file from the tmp directory to the uploads directory else { rename($tempdir.$tmp_file, $uploaddir.$upl_file); } } [/code] [b] Только когда загружается большой .heic -файл [/b], сценарий, кажется, поворачивает изображение BEI -90Deg. Когда небольшой файл. /> Я также проверил игру Arround с переменными $ max_image_resolution и $ max_image_width. Но это, кажется, зависит только от размера изображения.
Что такое прозрачные огромные страницы и почему следует отключать прозрачные огромные страницы в Red Hat Linux 7? Как прозрачные огромные страницы влияют на производительность настройки Linux?
Меня смущает концепция прозрачных огромных страниц....
У меня есть приложение консоли C#, которое пытается переместить каталог из одного места на C: Drive в другое место на C: Drive того же компьютера. Это работало, когда приложение было запущено на этом компьютере. Тем не менее, мои инструкции должны...
У меня есть приложение консоли C#, которое пытается переместить каталог из одного места на диске C: в другое место на диске C: того же компьютера. Это работало, когда приложение было запущено на этом компьютере. Тем не менее, мои инструкции -...
Я использую приведенный ниже код в своем автоматическом процессе для перемещения сообщения из папки «Входящие» в другую папку. Но немногие электронные письма не перемещаются. Это занимает 1-2 часа, иногда больше дня-двух.
var requestBody = new...
Мне нужно подключиться к серверу, где мой пользователь имеет доступ к одному небольшому разделу из /home/users/user_name, где у меня есть квота ограниченного пространства, и к большему разделу в /big_partition/users/user
После того, как я войду на...