The difference between this question and duplicates: keep the format of the content (png, jpeg, gif, webp) in order not to harm images with layers, transparency, etc. The others do not.
I have a file upload script , where I save the file to a folder, and write to the database the address:
if (!empty($_FILES['anexo']['name']) && ($fass[0]['status'] != 'C' && $fass[0]['status'] != 'F'))
{
$arqNome = $_FILES['anexo']['name'];
$extpat = pathinfo($_FILES['anexo']['name']);
$ext = $extpat['extension'];
$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/sys/files/';
$uploadfile = $tId . '-' . time();
$uploadatt = $uploaddir . $uploadfile . '.' . $ext;
if (move_uploaded_file($_FILES['anx']['tmp_name'], $uploadatt))
{
$dir = str_replace('\', '\\', $uploaddir);
$arq = $uploadfile;
$att = $arq . '.' . $ext; // $dir
if ($attc -> attachments($tId,$arqNome,$att,$solicitante))
{
header('location:../t_vis.php?id='. $tId);
}
}
}
I've been scanning, and have images attachments that are very large .
I would like to "compress / shrink" the image, for example Whatsapp does, but of course, without losing image quality, keeping file type (jpg, png, etc), so it does not "spoil" the original image with loss of layers, transparency, etc.
- Are there any native functions for this purpose?
- Are there libraries?
- Are there other ways?