B
B
blabs2016-11-30 23:14:12
PHP
blabs, 2016-11-30 23:14:12

How to automatically reduce the size of images on the server?

On the server, 80GB is occupied by PNG/JPG images. Pictures are scattered across different users and domains. About 20 domains. Many pictures weigh more than 2mb. Prompt a way which will allow to optimize images on the server.
The ideal scenario is this:
If a PNG/JPG file is over 2MB and its resolution is over 1024*800, we scale it down to 800*600 and compress the file to at least 0.5MB.
We use ISPManager 5 Lite.
Colleagues advised to use the PHP script through the terminal, but the script, unfortunately, was not completed to the end. Perhaps you can help with this.

find /var/www/{user1,user2,user3,user4,user5,user6}/data/www -type f -name *jpg -exec mogrify -quality 75% {} \;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mouvdy, 2016-12-01
@theblabs

So, as promised:
1. Bash option - pastebin.com/qp7LSLN5 edit and test it, preferably make a test user, just copy some /var/www/xxuser folder to /var/www/Testxxyser folder and test. I left comments. What you need is the minimum edit.
Run ./script.sh
2. PHP version with several API keys, copied a post from the forum, everything seems to be very clear: pastebin.com/gb44ejUq

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

Yuzay watcher that will monitor the appearance of new images on the site and compress in the background without losing quality,
for example, this one
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