D
D
Dmitry Sukhanov2016-06-22 23:13:04
PHP
Dmitry Sukhanov, 2016-06-22 23:13:04

How to compress images directly when uploading to the server?

I have always been interested in this question, there is little that is sensible on the Internet, the basics are online.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander Taratin, 2016-06-23
@Taraflex

In php by calling external utilities. If lossless, then the best
jpegtran
pngquant + PNGZopfli (first first, then second)

I
imhuman, 2016-06-22
@imhuman

imagick, gd there are a lot of manuals. www.php.su/articles/?cat=graph&page=014 at random

S
Sergey, 2016-06-22
Protko @Fesor

Purely theoretically, this is possible, especially with the advent of web assembly and the ability to use ready-made libraries for graphics optimization. Now it is very difficult.
There is a very simple way - aws s3 + aws lambda to upload files and process them after uploading to the server.

A
Alexey Cheremisin, 2016-06-22
@leahch

In my opinion, it makes no sense to compress images, they compress very badly. It only makes sense to change the resolution.
In php, compression on the fly, without an intermediate file, is most likely not to be done, but in Java - easily.

O
O. J, 2018-03-07
@OrlovEvgeny

You can hang a watcher that will monitor the appearance of new images in the directory and compress them,
for example this
https://github.com/OrlovEvgeny/TinyJPG

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question