Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6823531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:47:36+00:00 2026-05-26T21:47:36+00:00

I have a watermarking script, some of you might have seen before from one

  • 0

I have a watermarking script, some of you might have seen before from one of my previous questions:

<?php 

$imagesource = $_GET['path'];

$filetype = substr($imagesource,strlen($imagesource)-4,4);

$filetype = strtolower($filetype);

if($filetype == ".gif") $image = @imagecreatefromgif($imagesource);
if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource);
if($filetype == ".png") $image = @imagecreatefrompng($imagesource);

if (!$image) die();

$watermark = @imagecreatefrompng('watermark_'.(imagesx($image) <= 1100 ? "port" : "lans").'.png');

$imagewidth = imagesx($image);
$imageheight = imagesy($image);

$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);

$startwidth = (($imagewidth - $watermarkwidth)/2);
$startheight = (($imageheight - $watermarkheight)/2);

imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth,
$watermarkheight);

imagejpeg($image);

imagedestroy($image);

imagedestroy($watermark);

?> 

The script works fine, but when my client uploads a picture which is over 2000px X 2000px (or smething around there) the script outputs nothing not even an error. But, when I reduce it to 1100px X 800px for example this script outputs and displays the image. Is there any reason for this?

Is there anyway to either diagnose what is causing this and hence find a solution or to automatically re-size the image on upload?

This is the upload script I currently have:

<?php
if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg"))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("uploads/" . $_FILES["file"]["name"]))
      {
      echo "<h3>".$_FILES["file"]["name"] . " already exists. </h3>";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "uploads/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "<h3>Invalid file</h3>";
  }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:47:37+00:00Added an answer on May 26, 2026 at 9:47 pm

    Thanks to Josh I have found this direct solution which I have integrated. Thanks again!

    <?php
    if($_REQUEST['post']==1){
    if (($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg"))
      {
      if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    
    
    
        if (file_exists("uploads/" . $_FILES["file"]["name"]))
          {
          echo "<h3>".$_FILES["file"]["name"] . " already exists. </h3>";
          }
        else
          {
    
    // Temporary upload image name 
    $original_image = $_FILES['file']['tmp_name']; 
    
    // Get the image dimensions 
    $size=getimagesize( $original_image ); 
    
    // Name to save the image as - in this case the same as the original 
    $new_image = $_FILES['file']['name']; 
    
    // Maximum image width 
    $max_width = "1600"; 
    
    // Maximum image height 
    $max_height = "1600"; 
    
    // Resize the image and save 
    exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail $max_widthx$max_height $new_image"); 
    
    echo "File uploaded<br><br>"; 
    
    echo "<img src=\"'uploads/".$new_image."\" width=\"900\"><br><br>"; 
    
    
    $copy = copy($new_image, "uploads/".$new_image);
    $delete = unlink($new_image);
    
    if($copy){
          echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
    
          $date = date("d/m/y");
    
    
          $query  = mysql_query ('INSERT INTO  `ap_photos_list` ( `photo_id` ,  `category_id` ,  `subcategory_id` ,  `photo_name` ,  `photo_size` ,  `upload_date` ,  `filename` ) VALUES ("",  "'.$_REQUEST['category'].'",  "'.$_REQUEST['sub_category'].'",  "'.$_POST['textfield'].'",  "'.($_FILES["file"]["size"] / 1024).'KB",  "'.$date.'",  "'. $_FILES["file"]["name"].'")');
    
          $query  = mysql_query ('INSERT INTO  `ap_photos` ( `photo_id` ,  `category_id` ,  `subcategory_id` ,  `photo_name` ,  `photo_size` ,  `upload_date` ,  `filename` , `price` , `size` ) VALUES ("",  "'.$_REQUEST['category'].'",  "'.$_REQUEST['sub_category'].'",  "'.$_POST['textfield'].'",  "'.($_FILES["file"]["size"] / 1024).'KB",  "'.$date.'",  "'. $_FILES["file"]["name"].'" , "6.00" , \'6" x 4"\')');
          $query  = mysql_query ('INSERT INTO  `ap_photos` ( `photo_id` ,  `category_id` ,  `subcategory_id` ,  `photo_name` ,  `photo_size` ,  `upload_date` ,  `filename` , `price` , `size` ) VALUES ("",  "'.$_REQUEST['category'].'",  "'.$_REQUEST['sub_category'].'",  "'.$_POST['textfield'].'",  "'.($_FILES["file"]["size"] / 1024).'KB",  "'.$date.'",  "'. $_FILES["file"]["name"].'" , "8.00" , \'5" x 7"\')');
          $query  = mysql_query ('INSERT INTO  `ap_photos` ( `photo_id` ,  `category_id` ,  `subcategory_id` ,  `photo_name` ,  `photo_size` ,  `upload_date` ,  `filename` , `price` , `size` ) VALUES ("",  "'.$_REQUEST['category'].'",  "'.$_REQUEST['sub_category'].'",  "'.$_POST['textfield'].'",  "'.($_FILES["file"]["size"] / 1024).'KB",  "'.$date.'",  "'. $_FILES["file"]["name"].'" , "10.00" , \'8" x 6"\')');
          $query  = mysql_query ('INSERT INTO  `ap_photos` ( `photo_id` ,  `category_id` ,  `subcategory_id` ,  `photo_name` ,  `photo_size` ,  `upload_date` ,  `filename` , `price` , `size` ) VALUES ("",  "'.$_REQUEST['category'].'",  "'.$_REQUEST['sub_category'].'",  "'.$_POST['textfield'].'",  "'.($_FILES["file"]["size"] / 1024).'KB",  "'.$date.'",  "'. $_FILES["file"]["name"].'" , "12.00" , \'10" x 8"\')');
          $query  = mysql_query ('INSERT INTO  `ap_photos` ( `photo_id` ,  `category_id` ,  `subcategory_id` ,  `photo_name` ,  `photo_size` ,  `upload_date` ,  `filename` , `price` , `size` ) VALUES ("",  "'.$_REQUEST['category'].'",  "'.$_REQUEST['sub_category'].'",  "'.$_POST['textfield'].'",  "'.($_FILES["file"]["size"] / 1024).'KB",  "'.$date.'",  "'. $_FILES["file"]["name"].'" , "15.00" , \'12" x 8"\')');
    }else{
        echo "Unable to copy file";
    }
          }
        }
      }
    else
      {
      echo "<h3>Invalid file</h3>";
      }
    ?>
    
    <br />
    <br />
    <h3>
    <?php
    if($query){
        echo "Successful";
    }else{
        echo "Unsuccessful";
    }
    }
    ?>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have one Doubt In MVC Architecture we can able to pass data from Controller
Have some runtime defined schedule for one week, for example: <schedule> <s day=Monday, time=1:00:00></s>
I'm having an issue using a watermarking script I have. Below is the script:
Have deployed numerous report parts which reference the same view however one of them
have 2 questions : A computer with 32-bit address uses 2-level page table (9
have a nice day. I got problem when trying to create an image from
I have this code for watermarking text onto an image if($type==.jpg or $type==.jpeg){ $im
Have some code: using (var ctx = new testDataContext()) { var options = new
have Googled the cr*p out of this one so apologies if the answer is
Have a look at one of my websites: moskah.com The problem is that it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.