public function resampleImage()
    {
        $extension = strtolower($this->owner->getExtension());

        if($this->owner->getHeight() > $this->getMaxX() || $this->owner->getWidth() > $this->getMaxY()) {
            $original = $this->owner->getFullPath();
            $resampled = $original. '.tmp.'. $extension;

            $gd = new GD($original);

            if($gd->hasImageResource()) {
                $gd = $gd->resizeRatio($this->getMaxX(), $this->getMaxY());

                if($gd) {
                    $gd->writeTo($resampled);
                    unlink($original);
                    rename($resampled, $original);
                }
            }
        }
    }