-2

My users uploaded a image like that:

https://sim-t2b.s3.amazonaws.com/T2B%20-%20EXPRESS%20-%20MARCA/1/hipster-wallpaper-20.png

This have a 1 MB and i using this to a background a thumbnail:

Thumbnails

But my loading is increasing, i know that maybe is a duplicate, but there is a way that i don load this image with 1MB, maybe resize that to some kb, im using php, html, css and js

1 Answers1

1

You can use the GD and Image functions to resize/convert etc: http://php.net/manual/en/ref.image.php

If further compression is needed look into optipng

Royal Wares
  • 1,192
  • 10
  • 23
  • and i can use gd with a image from external source ? – Augusto Coelho Henriques Jun 14 '18 at 13:12
  • You would first need to get the image on your server for PHP to process and overwrite the original image, or save an alternate version in a different directory that you can link to. If you happen to own that S3 store then you can pull the image out of S3, process them, then put the images back onto the S3 store when you're done. – Royal Wares Jun 14 '18 at 13:15
  • there's no way to do this on the fly, without need to save a image on somewhere ? – Augusto Coelho Henriques Jun 14 '18 at 13:17
  • Technically yes, you could but it wouldn't be very practical. You could use something like file_get_contents to get the image from S3, process the image then represent it as a base64 encoded image in the "src" attribute of your "img" tag. The reason this isn't practical is because you're doing a lot of work which will most likely slow the generation time of your entire page to an unacceptable level. – Royal Wares Jun 14 '18 at 13:20