Actually RGB images are often stored by using 4 bytes as it makes the processing faster (and a few graphics cards use that format having one unused byte).

There is a way to reduce memory usage:

    imagepng($image);
    imagedestroy($image);

Having destroy will free the allocated memory after each step.

Memory usage for images is according to some sources:

    imagecreatetruecolor = width*height*5 bytes.
    imagepng = width*height*4 bytes.

Remember that GD needs to allocate memory for both the original and resized image.

We could also allocate more memory for the operation:

    ini_set('memory_limit', '1024M'); // Calculate memory usage instead of having hard coded value...

This seems to be the most commonly used calculation method:

http://www.dotsamazing.com/en/labs/phpmemorylimit