I have been trying to resize each image from database before pushing it into an array. The array contains the image path(URL) where I would like to display the resize image onto a grid view as the original images are too big and takes too long to load, hence the resizing. I have been figuring out the logic and still couldn't solve it. Could anyone help me with this? My database contains columns 'photo' and 'location'.
getphoto.php
<?php
require_once('dbConnect.php');
$sql = "select * from volleyupload1";
$res = mysqli_query($con, $sql);
$result = array();
while ($row = mysqli_fetch_array($res)) {
foreach ($result as $row['photo']) {
$imagick = new Imagick($row['photo']);
$imagick->thumbnailImage(300, 300, true, true);
header("Content-Type: image/jpg");
// echo $imagick;
}
array_push($result, array('url' => $row['photo'], 'location' => $row['location']));
// $test = $row['photo'];
// foreach ($result as $row['photo']){
// $imagick = new Imagick($row['photo']);
// $imagick->thumbnailImage(300, 300, true, true);
// header("Content-Type: image/jpg");
// echo $imagick;
//
// }
}
echo json_encode(array("result" => $result));
mysqli_close($con);