Checking if the field is not empty

I know this method

<?php if ($page->extract()->isNotEmpty()): ?> <?php endif; ?>

How to check if a page contains a photo, if so, display it:

     <img src="<?= $page->image()->url() ?>" alt="Logo">

I would be very grateful for your help. Have a nice day!

<?php if ($image = $page->image()): ?>
  <img src="<?= $image->url() ?>" alt="Logo">
<?php endif ?>

If no image exists, $page->image() will return null and thus the if-statement will not be entered.

Thank you!