( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/..//tmpr/../tmpr/..//tmpr/..//resizeGallery.php
<?php 

 $source ="v/uploads/gallery/05d087d0f98128bfff70ba514da061757djpg.jpg";
 $image_path="v/uploads/thumbs/016800e1ebbfaa7e627a650f2ba876542cappuccino.JPG"; 
 $w=600; 
 $h=600; 
 $size	= GetImageSize($image_path);
 $mime	= $size['mime'];	 
if (substr($mime, 0, 6) != 'image/')
{
header("Location: ./index.php?mode=photos&msg=requested file is not an accepted type");
exit();
} 
    //Get the original image dimensions + type
    list($source_width, $source_height, $source_type) = getimagesize($source);

    //Figure out if we need to create a new JPG, PNG or GIF
    $ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
    if ($ext == "jpg" || $ext == "jpeg") {
        $source_gdim=imagecreatefromjpeg($source);
    } elseif ($ext == "png") {
        $source_gdim=imagecreatefrompng($source);
    } elseif ($ext == "gif") {
        $source_gdim=imagecreatefromgif($source);
    } else {
        //Invalid file type? Return.
        return;
    }

    //If a width is supplied, but height is false, then we need to resize by width instead of cropping
    if ($w && !$h) {
        $ratio = $w / $source_width;
        $temp_width = $w;
        $temp_height = $source_height * $ratio;

        $background = imagecreatetruecolor($temp_width, $temp_height);
        imagecopyresampled(
            $background,
            $source_gdim,
            0, 0,
            0, 0,
            $temp_width, $temp_height,
            $source_width, $source_height
        );
    } else {
        $source_aspect_ratio = $source_width / $source_height;
        $desired_aspect_ratio = $w / $h;

        if ($source_aspect_ratio > $desired_aspect_ratio) {
            /*
             * Triggered when source image is wider
             */
            $temp_height = $h;
            $temp_width = ( int ) ($h * $source_aspect_ratio);
        } else {
            /*
             * Triggered otherwise (i.e. source image is similar or taller)
             */
            $temp_width = $w;
            $temp_height = ( int ) ($w / $source_aspect_ratio);
        }

        /*
         * Resize the image into a temporary GD image
         */

        $temp_gdim = imagecreatetruecolor($temp_width, $temp_height);
        imagecopyresampled(
            $temp_gdim,
            $source_gdim,
            0, 0,
            0, 0,
            $temp_width, $temp_height,
            $source_width, $source_height
        );

        /*
         * Copy cropped region from temporary image into the desired GD image
         */

        $x0 = ($temp_width - $w) / 2;
        $y0 = ($temp_height - $h) / 2;
        $background = imagecreatetruecolor($w, $h);
        imagecopy(
            $background,
            $temp_gdim,
            0, 0,
            $x0, $y0,
            $w, $h
        );
    }

    /*
     * Render the image
     * Alternatively, you can save the image in file-system or database
     */

    if ($ext == "jpg" || $ext == "jpeg") {
        ImageJpeg($background,$image_path,100);
    } elseif ($ext == "png") {
        ImagePng($background,$image_path);
    } elseif ($ext == "gif") {
        ImageGif($background,$image_path);
    } else {
        return;
    }

   
	
	header("Content-type: $mime");
	  if ($ext == "jpg" || $ext == "jpeg") {
        ImageJpeg($background,null,100);
    } elseif ($ext == "png") {
        ImagePng($background,null);
    } elseif ($ext == "gif") {
        ImageGif($background,null);
    } else {
        return;
    }
	 ImageDestroy ($background);
 ?>