From e75029fcba2be7a98246d5f537b0cfcb7fc68f08 Mon Sep 17 00:00:00 2001 From: Devdatt Bhatt Date: Thu, 21 May 2026 14:44:30 +0000 Subject: [PATCH] updtae --- encoder/app.php | 16 +++---- encoder/image.php | 115 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 94 insertions(+), 37 deletions(-) diff --git a/encoder/app.php b/encoder/app.php index 8f7936b..ac1280b 100644 --- a/encoder/app.php +++ b/encoder/app.php @@ -165,8 +165,8 @@ include 'header.php'; } -
-
+ +
@@ -236,10 +236,10 @@ include 'header.php'; + \ No newline at end of file diff --git a/encoder/image.php b/encoder/image.php index f6d53f5..1409102 100644 --- a/encoder/image.php +++ b/encoder/image.php @@ -12,10 +12,12 @@ $json_file = '/var/www/html/app.json'; $error_message = ''; // --- 1. Handle Form Submission BEFORE any HTML is rendered --- -if (isset($_POST['submit'])) { +if (isset($_POST['submit']) || isset($_POST['display'])) { $upload_paths = [ 'app_ad' => '/var/www/html/app_ad.png', - 'app_logo' => '/var/www/html/app_logo.png' + 'app_logo' => '/var/www/html/app_logo.png', + 'vertical_ad' => '/var/www/html/vertical_ad.png', + 'horizontal_ad' => '/var/www/html/horizontal_ad.png' ]; $secondary_dir = '/var/www/encoder/'; @@ -48,8 +50,16 @@ if (isset($_POST['submit'])) { continue; } - $target_width = ($input_name === 'app_logo') ? 128 : 256; - $target_height = ($input_name === 'app_logo') ? 128 : 256; + // Define dimensions based on input name + $dimensions = [ + 'app_logo' => [128, 128], + 'app_ad' => [256, 256], + 'vertical_ad' => [650, 850], + 'horizontal_ad' => [1920, 230] + ]; + + $target_width = $dimensions[$input_name][0]; + $target_height = $dimensions[$input_name][1]; // 3. Load the source image $src_img = @imagecreatefrompng($tmp_path); @@ -64,7 +74,7 @@ if (isset($_POST['submit'])) { // 5. Preserve transparency for PNG imagealphablending($dst_img, false); imagesavealpha($dst_img, true); - $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127); + $transparent = imagecolorallocatealpha($dst_img, 0, 0, 0, 127); imagefill($dst_img, 0, 0, $transparent); // 6. Resize (Resample) @@ -83,10 +93,10 @@ if (isset($_POST['submit'])) { // 7. Save to primary destination with compression (level 7) if (imagepng($dst_img, $destination, 7)) { - $filename = basename($destination); + $filename = basename($to_destination); $secondary_destination = $secondary_dir . $filename; - if (!copy($destination, $secondary_destination)) { + if (!@copy($destination, $secondary_destination)) { $errors[] = "Failed to create secondary copy for $input_name."; } } else { @@ -129,10 +139,32 @@ include 'header.php'; } -
+ + +
+ +

Image Assets Management

@@ -143,40 +175,65 @@ include 'header.php';
- -
-

Upload Ad (PNG)

+ +
+

App Logo (128x128)

- - -
New file selected
- -
- - + + +
+ +
- -
-

Upload Logo (PNG)

+ +
+

App Ad (256x256)

- - -
New file selected
- -
- - + + +
+ + +
+ +
+
+ + +
+

Vertical Ad (650x850)

+
+ + +
+ + +
+ +
+
+ + +
+

Horizontal Ad (1920x230)

+
+ + +
+ +
+
- +