Kirby Built in Server - GD dependency - OSX

Hi is there a dummies guide to using the built in Kirby server… on OSX Ventura?
Also specifically with the GD dependency, everything works fine until I try and use the images ->resize function, then my website just errors.
Im pretty sure it’s something to do with GD from reading around. Just know idea how to install it.
I am using the built in php server that comes with the Mac OS

First step would be to print phpinfo() to check if GD is installed.

That’s pretty vague, what exactly?

Hi Apologies,

php -i | grep 'GD\|ImageMagick'

returns…

GD Support => enabled
GD headers Version => 2.3.3
GD library Version => 2.3.3
phpinfo()

returns…

function>

The error I receive from the debug mode is… “Call to a member function crop() on null” Code below… its the line with the crop function which errors, however same if I use resize.

<ul class="projects">
 
 
    <?php 
    $vari = page('portfolio');
 
    foreach ($vari->children()->listed() as $image): ?>
    <li>
        <a href="<?= $image->url() ?>">
 
            <figure>
 
                <?= $image->image()->crop(200, 200) ?>
 
            </figure>    
        </a>
    </li>
    <?php endforeach ?>            
</ul>

Thanks

Your error has nothing to do with GD being present or not. The error tells you that $image->image() return null and then you try to call crop() on null. You need to check if you have an image before you call any member method.

Hi do you know how I would go about that?
The image is there and the page works when I remove crop or resize,
I was following the Kirby YouTube video on building a project grid How to build a project grid - YouTube
Everything works fine until I try to resize the images

The correct way to go about this is this:

<?php 
    $vari = page('portfolio');
 
    foreach ($vari->children()->listed() as $p): ?>
       <?php if ($image = $p->image()): ?>
    <li>
        <a href="<?= $p->url() ?>">

            <figure>
 
                <?= $image->crop(200, 200) ?>
 
            </figure>    
        </a>
    </li>
   <?php endif ?>
    <?php endforeach ?>            
</ul>
1 Like

Thank you!