Search code examples
phpimagegdlib

Cannot copy and resample an image with PHP


I am trying to copy a resampled image. Something seems not working:

copy($_FILES['image']['name'],'logo.png');
$dir_subida = 'C:\xampp5\htdocs\bild';
$source = imagecreatefrompng($_FILES['image']['name']);
$destination = imagecreatefrompng($dir_subida . '\\logo.png');
imagecopyresampled($destination,$source,0,0,0,0,110,55,600,220);

First I copy the image and save it in a directory. Then, I define the source (an image that I am uploading in a form). Then I define the destination.

Then I try to resample and copy it with the default function imagecopyresampled.

It just copies the image right away without any kind of changes.

Am I missing something?


Solution

  • You must save the destination image to a file after you manipulate it.

    imagepng($destination, 'c:\\path\\to\\file.png');