<?php require "smartyStarter.php"; require "Picture.php"; $pictures = new Picture($local_database, $local_username, $local_password); $picture_id = isset($_REQUEST["picture_id"]) ? $_REQUEST["picture_id"] : ""; $rotatedPic = $pictures->loadPicture($picture_id); $picName = $rotatedPic['filename']; $extension = $rotatedPic['extension']; $filepath = $rotatedPic['path']; if (strlen($picName) < 3) { $rotatedBy = ""; $coreName = $picName; } else { $rotatedBy = substr($picName, strlen($picName) - 2, 2); if ($rotatedBy == '_a' || $rotatedBy == '_b' || $rotatedBy == '_c') { $coreName = substr($picName, 0, strlen($picName) - 2); } else { $coreName = $picName; } } function ifFileDoesntExistRotate($newFilepath, $filepath) { if (!file_exists($newFilepath)) { $degrees = -90; header('Content-type: image/JPG'); $source = imagecreatefromjpeg($filepath); $rotate = imagerotate($source, $degrees, 0); imagejpeg($rotate, $newFilepath); //save the new image imagedestroy($source);