Help to Refactor PHP Flip Image Code to smallest size as possible
You could use call_user_func to check the extension only once. Something like this (I haven't got the time even to read the code now) 

function flip_image($filepath)
{
if(file_exists($filepath)):

    //Array ( [dirname] =&gt; images 
    //        [basename] =&gt; pig.png 
    //        [extension] =&gt; png 
    //        [filename] =&gt; pig 
    //        [filesize] =&gt; 72 )
    $file = $this-&gt;get_file_info($filepath); // Returns above array

    // Is it allowed in our extensions array
    if(in_array($file['extension'], $this-&gt;allowed_exts)):
         // Reference our Image for the correct extension
        $outfile = $file['dirname'] . "/" . $file['filename'] . "_flipped" . "." . $file['extension'];
        switch ($file['extension']) {
            case 'png':
                return flip_image_in($filepath, $outfile, 'imagecreatefrompng', 'imagepng');
            case 'gif':
                return flip_image_in($filepath, $outfile, 'imagecreatefromgif', 'imagegif');
            default: // Has to be JPG, or JPEG
                return flip_image_in($filepath, $outfile, 'imagecreatefromjpeg', 'imagejpeg');
        }
    else:
        echo 'Incorrect File Type, Not an Image, .png .gif, jpeg. jpeg Only.';
        return false;
    endif;
else:
    echo 'No Such file found, Check the file path';
    return false;
endif;

}

function flip_image_in($inpath, $outfile, $create_function, $write_function)
{
        $img = call_user_func($create_function, $inpath);

        // Now we have our image...
        // Image Width &amp; Height
        $size_x = imagesx($img);
        $size_y = imagesy($img);

        // Create Temp Image
        $temp = imagecreatetruecolor($size_x, $size_y);

        // Define a colour as transparant, allocate the colour, resample it
        imagecolortransparent($temp, imagecolorallocate($temp, 0, 0, 0));
        imagealphablending($temp, false);
        imagesavealpha($temp, true);

        $x = imagecopyresampled($temp, $img, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y);
        if ($x) {
            $img = $temp;
        }
        else {
            die('Unable to flip image');
        }

        call_user_func($write_function, $img, $outfile);
        imagedestroy($img);
        return $outfile;
}