Skip to content

MiniImg is a web-based application for compressing and optimizing images.

License

Notifications You must be signed in to change notification settings

lindevs/mini-img

Repository files navigation

MiniImg

MiniImg is a web-based application for compressing and optimizing PNG, JPEG, WebP, GIF, and SVG images using various command line tools.

MiniImg

Prepare environment

Requirements

MiniImg requires the following packages:

  • PHP 8.3
  • Apache 2.4
  • Composer
  • Node.js and npm

For images compression and optimization you need to have the following tools:

  • optipng
  • pngquant
  • jpegoptim
  • cwebp
  • gifsicle
  • svgo

Install optimizers

On Ubuntu/Debian, optimizers can be installed using the following commands:

sudo apt update
sudo apt install -y optipng
sudo apt install -y pngquant
sudo apt install -y jpegoptim
sudo apt install -y webp
sudo apt install -y gifsicle
sudo npm install -g svgo

On Windows, prebuilt binaries can be downloaded using the following links:

Make sure your binaries are added to PATH environment variable that allows to locate executables from the command line.

Configure PHP

  • Set the value of upload_max_filesize and post_max_size in your php.ini to control upload file size:
upload_max_filesize = 40M
post_max_size = 40M

Configure Apache

  • Directory root should be pointed to public directory. For example, you can edit a default virtual host file that provided on Ubuntu/Debian:
sudo nano /etc/apache2/sites-available/000-default.conf

Example of configuration file:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public

    <Directory /var/www/html/public>
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  • A mod_rewrite module should be enabled for Apache. On Ubuntu/Debian, run the following commands:
sudo a2enmod rewrite
sudo service apache2 restart

Install MiniImg

  • Download MiniImg:

    • curl -Lo mini-img.tar.gz https://github.com/lindevs/mini-img/archive/master.tar.gz
  • Extract files to your www directory:

    • Linux: tar xf mini-img.tar.gz --strip-components=1 -C /var/www/html
    • Windows: tar xf mini-img.tar.gz --strip-components=1 -C C:\wamp64\www
  • Go to MiniImg root directory:

    • Linux: cd /var/www/html
    • Windows: cd C:\wamp64\www
  • Install composer packages:

    • composer install --optimize-autoloader --no-dev
  • Copy .env.example file to .env:

    • Linux: cp .env.example .env
    • Windows: copy .env.example .env
  • Open .env file and modify the following options:

APP_ENV=prod
APP_DEBUG=false
  • Generate application key:

    • php artisan key:generate
  • Cache the bootstrap files:

    • php artisan optimize
  • Change directory permissions (only Linux):

    • chmod -R 777 storage bootstrap/cache public/uploads
  • Install npm packages:

    • npm install
  • Compile assets:

    • npm run build
  • Open browser and navigate to http://localhost

Note: To run commands in Linux requires root or user with sudo privileges.

Development

  • Go to your www directory:

    • Linux: cd /var/www/html
    • Windows: cd C:\wamp64\www
  • Clone MiniImg repository:

    • git clone https://github.com/lindevs/mini-img.git .
  • Install composer packages:

    • composer install
  • Copy .env.example file to .env:

    • Linux: cp .env.example .env
    • Windows: copy .env.example .env
  • Generate application key:

    • php artisan key:generate
  • Change directory permissions (only Linux):

    • chmod -R 777 storage bootstrap/cache public/uploads
  • Install npm packages:

    • npm install
  • Compile assets and watch file changes:

    • npm run dev

Note: To run commands in Linux requires root or user with sudo privileges.

License

The code in this repository is licensed under the Apache License 2.0.

About

MiniImg is a web-based application for compressing and optimizing images.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published