Jump to content

Drawing file suddenly not working


Nodral

Recommended Posts

Hi

 

I have created the following file to output results from a questionnaire in a visual way.  This was working absolutely fine, but now has decided to stop working.  All I did was navigate to a different web page.  I have tried closing my browser and clearing cache etc but still it won't output to a web page.

 

I get the windows pop-up of 'Open, Save or Cancel'  If I chose open, it simply opens the file in notepad.

 

Any ideas?

 

<?php

//Create image size and initiate
$image=imagecreate(1000,1000);

//Allocate colours (1st is always background)

$background=imagecolorallocate($image, 255, 255, 255);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
$red = imagecolorallocate($image, 255, 0, 0);

//array of results
$activist=10;
$reflector=18;
$theorist=17;
$pragmatist=9;

//set zeros for x & y
$x=500;
$y=500;

//change results into coordinates
$values=array(
$x, $y-($activist*20),
$x+($reflector*20), $y,
$x, $y+($theorist*20),
$x-($pragmatist*20), $y);




//create vertices
//x axis
imageline($image, 500, 100, 500, 900, $black);

//y axis
imageline($image, 100, 500, 900, 500, $black);

// create picture

imagefilledpolygon($image, $values, 4, $black);
//change to outline


//add titles

// Path to our ttf font file
$font_file = 'arial.ttf';

//create labels for axis
imagefttext($image, 20, 0, 450,50,$black, 'arial.ttf',"Activist" );
imagefttext($image, 20, 0, 450,950,$black, 'arial.ttf',"Theorist" );
imagefttext($image, 20, 90, 50,550,$black, 'arial.ttf',"Pragmatist" );
imagefttext($image, 20, 90, 950,550,$black, 'arial.ttf',"Reflector" );

//create labels for co-ordinates
imagefttext($image, 20, 0, $x, $y-($activist*20)-50,$red, 'arial.ttf',"$activist" );
imagefttext($image, 20, 0, $x, $y+($theorist*20)+50,$red, 'arial.ttf',"$theorist" );
imagefttext($image, 20, 0, $x-($pragmatist*20)-50,$y,$red, 'arial.ttf',"$pragmatist" );
imagefttext($image, 20, 0, $x+($reflector*20)+50,$y,$red, 'arial.ttf',"$reflector" );

//set header
header("content-type:image.png");

//produce image

imagepng($image);




?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.