public static function resize($options = null)
    {
        $options = Helper::getOptions($options, [
            "fromPath"  =>  null,
            "toPath"    =>  null,
            "width"     =>  null,
            "height"    =>  null,
        ]);

        if (!$fromPath = trim($options["fromPath"])) {
            throw new \Exception("No from path specified to read from");
        }
        if (!$toPath = trim($options["toPath"])) {
            throw new \Exception("No to path specified to save to");
        }
        $maxWidth = round($options["width"]);
        $maxHeight = round($options["height"]);

        list($width, $height, $format) = getimagesize($fromPath);

        if ($width < 1 || $height < 1) {
            copy($fromPath, $toPath);
            return;
        }

        if ($maxWidth < 1 && $maxHeight < 1) {
            copy($fromPath, $toPath);
            return;
        }

        if ($width < $maxWidth && $height < $maxHeight) {
            copy($fromPath, $toPath);
            return;
        }

        $newWidth = $width;
        $newHeight = $height;

        if ($maxHeight && $newHeight > $maxHeight) {
            $ratio = $newWidth / $newHeight;
            $newHeight = $maxHeight;
            $newWidth = $newHeight * $ratio;
        }

        if ($maxWidth && $newWidth > $maxWidth) {
            $ratio = $newHeight / $newWidth;
            $newWidth = $maxWidth;
            $newHeight = $newWidth * $ratio;
        }

        $image = static::create($fromPath, $format);
        $newImage = imagecreatetruecolor($newWidth, $newHeight);

        if ($format != IMAGETYPE_JPEG) {
            imagealphablending($newImage, false);
            imagesavealpha($newImage, true);
            $background = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
            imagecolortransparent($newImage, $background);
        }

        imagecopyresampled($newImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
        static::save($newImage, $toPath, $format);

        imagedestroy($image);
        imagedestroy($newImage);
    }