1
$image = imagecreatefromjpeg('http://localhost/test/wp-content/uploads/2014/09/city_81.jpg');

// choose a color for the ellipse
$ellipseColor = imagecolorallocate($image, 0, 0, 255);

// draw the white ellipse
imagefilledellipse($image, 500, 100, 6, 6, $ellipseColor);

// Output the image.
header("Content-type: image/jpeg");
imagejpeg($image);

But when I try to run the same code within wordpress it doesn't work . It outputs some garbage value, and as well as warning

Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\test\wp-includes\general-template.php:2752)

  • I have GD library installed and enabled and allow_url_fopen = on – Mithun Sarker Shuvro Sep 25 '14 at 12:11
  • make sure that there is no white spaces before the php opening tag "<?php" and after end tag "?>" – Zammuuz Sep 25 '14 at 12:15
  • yeah it is checked – Mithun Sarker Shuvro Sep 25 '14 at 12:16
  • did u try using separate php file for header code like in here stackoverflow.com/questions/11358484/… – Zammuuz Sep 25 '14 at 12:18
  • 2
    Well, you actually sent a header("Content-type: image/jpeg");, so this is pretty much expected behavior. Don't send headers from the middle of your template. And please edit your question and show in which context you are including the code. Also: Add your "garbage value" - it might be important (as everything that comes with an error). – kaiser Sep 25 '14 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.