// Convert PNG-images to JPEG // Pass the image url and new url to it public function convertToJpeg($oldUrl, $newUrl) { $source = imagecreatefrompng($oldUrl); $imgX = imagesx($source); $imgY = imagesy($source); $dest = imagecreatetruecolor($imgX, $imgY); imagecopy($dest, $source, 0, 0, $imgX, $imgY, $imgX, $imgY); imagejpeg($dest, $newUrl); imagedestroy($dest); imagedestroy($source); // Set new values $this->imageLocation = $newUrl; $temp = explode("/", $newUrl); $this->imageName = end($temp); }