I created an image in a file called "gen_height.pht"
<?php
header("Content-type: image/png");
$font_file = "../../01 fonts/fonts Google/alef-bold.ttf";
$font_size = 300;
$text = "i";
$width = 400;
$height = 400;
$im = imageCreate ($width, $height);
$background_color = imagecolorallocate($im, 255, 255, 255);
$fontcolor = imagecolorallocate($im, 0, 0, 0);
imageTTFText ($im, $font_size, 0, 0, 400, $fontcolor, $font_file, $text);
imagepng($im);
imagedestroy($im);
?>
Now I place this image into a html canvas:
function load_canvas () {
var canvas = document.getElementById('canvas_height');
var context = canvas.getContext('2d');
img_height = new Image();
img_height.src = 'generators/gen_height.php';
context.drawImage(img_height, 0, 0);
}
And after that, I want to know the imagedate (rgb values), with:
function tester1() {
var canvas = document.getElementById('canvas_height');
var context = canvas.getContext('2d');
DATA_TRIANGLE = context.getImageData(0, 0, 400, 400).data;
text = '';
var j = 0;
var pixels = new Array();
for (var i = 0; i < 6400; i++) {
text += DATA_TRIANGLE[i] + ', ';
}
document.getElementById('testdiv').innerHTML = text;
}
• the php image appears
• but the imagedata is all 255's (output from function tester1), like there is only a white background
• when I replace the php image for a regular jpg image, it does work and gives specific rgb-data
Anyone an idea why I don;t get data out of the php-image, while it does appear?