-1

Index.php

<?php

    error_reporting(E_ALL);
    // File and new size
    //the original image has 800x600
    $filename = 'images/lazy1.jpg';
    //the resize will be a percent of the original size
    $percent = 0.5;

    // Content type
    header('Content-Type: image/jpg');

    // Get new sizes
    list($width, $height) = getimagesize($filename);
    $newwidth = $width * $percent;
    $newheight = $height * $percent;

    // Load
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $source = imagecreatefromjpeg($filename);

    // Resize
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    // Output and free memory
    //the resized image will be 400x300
    imagejpeg($thumb, "raj.jpg", 100);
    imagedestroy($thumb);
echo "Image Resize Successfully";
    ?>

I am using imagejpeg() to save file. i want save file in folder but not show on browser. in browser only show this message "Image Resize successfully".

Rajkeshar
  • 75
  • 10

1 Answers1

3
<?php

    error_reporting(E_ALL);
    // File and new size
    //the original image has 800x600
    $filename = 'images/lazy1.jpg';
    //the resize will be a percent of the original size
    $percent = 0.5;

    //Removed lines here

    // Get new sizes
    list($width, $height) = getimagesize($filename);
    $newwidth = $width * $percent;
    $newheight = $height * $percent;

    // Load
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $source = imagecreatefromjpeg($filename);

    // Resize
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    // Output and free memory
    //the resized image will be 400x300
    imagejpeg($thumb, "raj.jpg", 100);
    imagedestroy($thumb);
    echo "Image Resize Successfully";
    ?>
Loïc
  • 11,804
  • 1
  • 31
  • 49