I have some images in my S3 bucket on AWS. I am trying to get the images and send them to my android app (along with other information from my database). My current setup works fine but I would like to reduce the image file sizes (currently around 1-1.5mb) before I send them to the app.
I have tried to use this code:
function compress($source, $destination, $quality) {
$info = getimagesize($source);
if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source);
elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source);
elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source);
imagejpeg($image, $destination, $quality);
return $destination;
}
$image_file = Storage::disk('s3_upload')->get("s3bucketpath");
$new_image_file = $this->replace_extension($image->filename, '.jpg');
$this->compress($image_file,$new_image_file, 50);
I get
failed to open stream: No such file or directory in file
error from
$info = getimagesize($source);
I have checked the file path and it is in the bucket and exists and I have var-dumped source and gotten
�����JFIF���������C�$<'$!!$J58,<XM\[VMUSam�vag�hSUy�z������^t������������C$ $G''G�dUd�����������������������������������������������������@0"�����������������A�����!1A"Q2aq#B���3R�$4b�rC���%S���5D������������������#�����!1A2"Q#�����?���HS-�� ��� ��B�@�)��( @������ @����!@��������������(�����(����� � @����UF�LHU@�d �� @ �����)������@R��B����(�R���E]��( (� @B'...
What is the best way to go about doing this.