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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:52:58+00:00 2026-06-07T01:52:58+00:00

Few days ago i was looking for way to use my custom php on

  • 0

Few days ago i was looking for way to use my custom php on wordpress site and i found answer here: How to add a php page to WordPress.
Tried few examples and it worked well for each of them. But then i wanted to go further and use PHP image processing in wordpress page added like that. It works on normal php site (using JUST this code), but when i try to use it in worpress i get error:

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\twentyeleven\header.php:13) in C:\xampp\htdocs\wordpress\wp-content\themes\twentyeleven\mynewsite.php on line 26

My code i am trying to use is:

<?php
$dest = imagecreatefrompng('image1.png');
$src = imagecreatefromjpeg('image2.jpg');

imagealphablending($dest, false);
imagesavealpha($dest, true);
imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //putting one image on top of other

header('Content-Type: image/png');
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
?>

Well i know the problem is i am trying to send header here, but i dont know how to solve it.
I tried moving this header to top of the file, but then whole worpress site don’t load.

header('Content-Type: image/png');
get_header(); //<-- part of wordpress template, cant get rid of it, cuz it ruins whole site look.

So looks like get_header(); is somehow "problem" here.
Tried using ob_start(), flush, clean etc, but then i get the image i want, without worpress site loading. I ran out of options, and non of these solved my problem.

My question is: How to send this header to make it work, cuz without it i see some weird symbols instead of png image (like i would open png image with notepad)

Any help appreciated.

  • 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-06-07T01:53:00+00:00Added an answer on June 7, 2026 at 1:53 am

    Okay, found solution to this. Posting answer as it might be useful for someone else in the future.

    So I will be using simple words, which made me understand this.
    header('Content-Type: image/png'); makes whole site to be “treated as image”. So when I even found the place where to put my header in WordPress files, it still didn’t show any result at all. To solve this problem, just create another file called image.php and put the PHP GD code there.

    $dest = imagecreatefrompng('image1.png');
    $src = imagecreatefromjpeg('image2.jpg');
    imagealphablending($dest, false);
    imagesavealpha($dest, true);
    imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //putting one image on top of other
    header('Content-Type: image/png');
    imagepng($dest);
    imagedestroy($dest);
    imagedestroy($src);
    

    Of course in <?php ?> tags, and in WordPress page, where you want display it use <img src = "image.php">. This will get rid of all errors with headers, and also will display already created image by this PHP code.

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

Sidebar

Related Questions

A few days ago, this was my question, and I found the answer. Maybe
I found a few days ago a nice site with a big table with
A few days ago I posted this question and everyone suggested me to use
I asked on SO a few days ago what was the simplest quickest way
Few days ago all was ok: when I started my web-site with Silverlight 4.0
few days ago I asked here about implementing USB. Now, If I may, would
A few days ago, I watched the video tutorial which explains how to use
few days ago, when I was debugging an Android project under eclipse I've found
few days ago i've changed host for my site, and now on the new
A few days ago we replaced our web site with an updated version. The

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.