Scale and rotate images to create a simple gallery

This is a very simple script which I use to convert images scaling the image down from the Canon default JPEG 3888x2592 by a tenth to a sane thumb value storing the image in the thumb folder. Also I use the EXIF data to get the correct orientation and rotate the image.

<?php
$images = glob('*.JPG');
foreach($images as $image)
{
        $source = basename($image, '.JPG');
        $target = 'thumb/' . $image;
        if(file_exists($target))
        {
        }
        else
        {
                list($width, $height, $type, $attr) = getimagesize($image);
                $thumbwidth = intval($width/10);
                $thumbheigt = intval($height/10);
                scale($thumbwidth , $thumbheigt, $path . $image, $path . $target);
                $path = getcwd().'/';
                $exif = exif_read_data($image, 'EXIF');
                $computed = $exif['COMPUTED'];
                $html = $computed['html'];
                $orientation = $exif ['Orientation'];
                switch($orientation)
                {
                        case 1:
                                break;
                        case 6:
                                rotate('90', $path . $image, $path . $image);
                                rotate('90', $path . $target, $path . $target);
                                break;
                        case 8:
                                rotate('270', $path . $image, $path . $image);
                                rotate('270', $path . $target, $path . $target);
                                break;
                        default:
                                break;
                }
        }
}
function scale($width, $height, $source, $target)
{
        $convertCommand = 'convert -geometry ' . $width . 'x' . $height . '!' . ' "' . $source . '" "' . $target.'"';
        echo $convertCommand . PHP_EOL;
        exec($convertCommand);
}
function rotate($degrees, $source, $target)
{
        $convertCommand = 'convert -rotate ' . $degrees . ' "' . $source . '" "' . $target.'"';
        echo $convertCommand . PHP_EOL;
        exec($convertCommand);
}
?>