A
A
Alexander Laikov2015-08-20 18:45:54
PHP
Alexander Laikov, 2015-08-20 18:45:54

Changing the original image. What am I doing wrong?

It is required to change the original image depending on the exposed data.
There is a small sketch:

$image_p;
$filename = "template/assets/images/skins/290.png";
$image_p = imagecreatetruecolor(20, 20);
$image = imagecreatefrompng($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 20, 20, 20, 20);
header('Content-type: image/png');//29 строка
imagepng($image_p);

result of the operation:
8b730381a47f42d8bdb2e96f8c7ef3dd.png
What did I do wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2015-08-20
@scherbuk

Something was deduced before header('Content-type: image/png');//line 29, I suppose
also check that the file without BOM is saved

K
Ken Jee, 2015-08-20
@Machez

If you translate the text of the error from English into Russian, you will know that you are informed that the headers have already been sent to the user before. Search "higher" in the code for calls to output functions (more often this isecho ).

A
Alexander Laikov, 2015-08-20
@Florens

Fixed the problem.
But I have an editable .png file, which means it can have "transparent places"
But imagecreatetruecolor creates a black background
As a result, an undesirable result in the form of a black square is obtained
How can this be fixed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question