Aleric Aleric - 1 month ago 11
PHP Question

PHP--Image Copy Resize won't save reduced photo

My jpg is 4kb, but when I upload it to the server, the PHP program writes it much larger, as 43kb, it's large and fuzzy, instead of being small and clear. How can I maintain the width and height? I've tried resizing after the photo is saved, but nothing happens. This is the code for the upload, and save.

<?php
// retrieve
echo "Request received";


$p= $_FILES["file"];
move_uploaded_file($p["tmp_name"], "pic3-1.jpg");

if ($p==nil) { echo "no photo"; }

// reply
$data = Array("Reply"=>"Imaged saved at server");
echo json_encode($data);

?>

Answer

Added to Xcode 8, Swift 3. The resolution is clear:

    UIGraphicsBeginImageContext(CGSize(width:75, height: 75))
    photo2.draw(in: CGRect(x: 0, y: 0, width: 75, height: 75))
    photo=UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()