2
The difference from this question to duplicates: keep the content format (png, jpeg, gif, webp), in order not to harm images with layers, transparency, etc. The others do not have.
I have a file upload script, where I save the file to a folder, and write the address to the database:
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 checking, and there are attachments images who are very large.
I would like to "compress/decrease" the image, as for example Whatsapp does, but of course, without losing the image quality, maintaining file type (jpg, png, etc), so does not "spoil" the original image with the loss of layers, transparency, etc.
- There are native functions for this purpose?
- There are libraries?
- There are other ways?
compress/decrease the image without losing image quality and without changing the type is impossible... some information needs to be removed or decreased, such as file metadata information (photo location, comments, etc), resolution and number of colors, for example.
– Dudaskank