Important note: When the imagedestroy is called, the resource is freed but the printed resource output is the same as before calling the function:<?php $img = imagecreate(1, 1); print_r([$img, $img ? 'TRUE': 'FALSE', is_resource($img) ? 'TRUE' : 'FALSE', get_resource_type($img) ?: 'FALSE']); imagedestroy($img); print_r([$img, $img ? 'TRUE': 'FALSE', is_resource($img) ? 'TRUE' : 'FALSE', get_resource_type($img) ?: 'FALSE']); ?>As you can see in the above example, the first index in array is TRUE in both cases. So, despite the common thinking you can't trust in something like:<?php if ($img) { }?>If you need to ensure the availability of a certain resource, you must to use is_resource and get_resource_type functions.