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 7625605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:12:51+00:00 2026-05-31T05:12:51+00:00

Im facing a very annoying problem in PHP when Im trying to watermark the

  • 0

Im facing a very annoying problem in PHP when Im trying to watermark the full size images on my website. The watermark was working fine for weeks but all the sudden it started showing this error : the image “bla bla” cannot be displayed because it contains errors

I checked everything and everything seems to be working just fine! I’m stuck and I dont know what to do.

Here is my watermarking php file:

require_once "maincore.php";

if (isset($_GET['photo_id']) && isnum($_GET['photo_id'])) {

    $result = dbquery("SELECT td.*, tc.* FROM ".DB_PRODUCTS." td LEFT JOIN ".DB_PRODUCT_CATS." tc ON td.product_cat=tc.cat_id WHERE product_id='".$_GET['photo_id']."'");

    $data = dbarray($result);

        define("PHOTODIR", BASEDIR."downloads/images/");

        $parts = explode(".", $data['product_image']);

        $wm_file1 = $parts[0]."_w1.".$parts[1];

        $wm_file2 = $parts[0]."_w2.".$parts[1];

        if (!isset($_GET['full'])) {

            $wm_file = PHOTODIR.$wm_file1;

        } else {

            $wm_file = PHOTODIR.$wm_file2;

        }

        header("Content-type: image/jpg");

        $img = PHOTODIR.$data['product_image'];

        $cop = BASEDIR.$settings['photo_watermark_image'];

        if (preg_match("/.jpg/i", strtolower($img)) || preg_match("/.jpeg/i", strtolower($img))) {

            $image = imagecreatefromjpeg($img);

        } else if (preg_match("/.png/i", strtolower($img))) {

            $image = imagecreatefrompng($img);

        } else if (preg_match("/.gif/i", strtolower($img))) {

            $image = imagecreatefromgif($img);

            $sizeX = imagesx($image);

            $sizeY = imagesy($image);

            $image_tmp = imagecreatetruecolor($sizeX, $sizeY);

            $ica = imagecolorallocate($image_tmp, 255, 255, 255);

            imagefill($image_tmp, 0, 0, $ica);

            if ($settings['thumb_compression'] == "gd2") {

                imagecopyresampled($image_tmp, $image, 0, 0, 0, 0, $sizeX, $sizeY, $sizeX, $sizeY);

            } else {

                imagecopyresized($image_tmp, $image, 0, 0, 0, 0, $sizeX, $sizeY, $sizeX, $sizeY);

            }

            $tmp = PHOTODIR.md5(time().$img).'.tmp';

            imagejpeg($image_tmp, $tmp);

            imagedestroy($image_tmp);

            $image = imagecreatefromjpeg($tmp);

            unlink($tmp);

        }

        if (file_exists($cop) && preg_match("/.png/i", strtolower($cop)) && $settings['photo_watermark']) {

            $image2 = false;

            $image_dim_x = imagesx($image);

            $image_dim_y = imagesy($image);

            $copyright = imagecreatefrompng($cop);

            $copyright_dim_x = imagesx($copyright);

            $copyright_dim_y = imagesy($copyright);

            $where_x = $image_dim_x - $copyright_dim_x - 5;

            $where_y = $image_dim_y - $copyright_dim_y - 5;

            imagecopy ($image, $copyright, $where_x, $where_y, 0, 0, $copyright_dim_x, $copyright_dim_y);

            $thumb_w = 0; $thumb_h = 0;

            if (!isset($_GET['full'])) {

                if ($image_dim_x > $settings['photo_w'] || $image_dim_y > $settings['photo_h']) {

                    if ($image_dim_x  $image_dim_y) {

                        $thumb_w = $settings['photo_w'];

                        $thumb_h = round(($image_dim_y * $settings['photo_w']) / $image_dim_x);

                    } else {

                        $thumb_w = $settings['photo_w'];

                        $thumb_h = $settings['photo_h'];

                    }

                } else {

                    $thumb_w = $image_dim_x;

                    $thumb_h = $image_dim_y;

                }

                $image2 = imagecreatetruecolor($thumb_w, $thumb_h);

                if ($settings['thumb_compression'] == "gd2") {

                    imagecopyresampled($image2, $image, 0, 0, 0, 0, $thumb_w, $thumb_h, $image_dim_x, $image_dim_y);

                } else {

                    imagecopyresized($image2, $image, 0, 0, 0, 0, $thumb_w, $thumb_h, $image_dim_x, $image_dim_y);

                }

                imagedestroy($image);

            }

        }

        //create image

        if ($settings['photo_watermark_save']) { imagejpeg(($image2 ? $image2 : $image), $wm_file); }

        imagejpeg((isset($image2) && $image2 ? $image2 : $image));

        imagedestroy((isset($image2) && $image2 ? $image2 : $image));

        if (isset($copyright) && is_resource($copyright)) {  ImageDestroy($copyright); }

} else {

    redirect("index.php");

}

Please Help ME! Thank you!

  • 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-31T05:12:52+00:00Added an answer on May 31, 2026 at 5:12 am

    Is php.ini set with display_errors turned on? If so, your code may be throwing a warning or notice which is getting incorporated into the binary image data and corrupting it.
    Check your PHP error log for new entries.

    Another possibility is that an include file is outputting whitespace by having multiple blank lines in the bottom below the closing PHP tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m facing very weird problem in wordpress wp-admin. I was trying to upload
I'm facing a very annoying problem. Here's the context : I have a rectangle
im not very experienced in php. The problem i'm facing is: print post: {$_POST['var']}
I'm facing very strange problem - my app is working nice on a device
This is a very basic and silly question but i am facing this problem
I am facing a very strange problem where the same loop keeps giving me
In my 2nd ASP.NET MVC project I'm facing a very weird problem: when I
I'm facing a problem with IE6. I took the toggle function from this website
I am currently facing a very disturbing problem: interface IStateSpace<Position, Value> where Position :
I am facing a very strange problem with editingStyleForRowAtIndexPath method. I am planing to

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.