Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Author: @way2enjoy2


When we write articles or build websites, we often need to compress the images to help users save traffic and increase the speed of website loading.

There are MANY Ways to the compress Images. Of The Recommended One here Wallpaper IS Way2enjoy . Way2enjoy IS AN Online compression Tool. Of The main Advantage IS that IT Achieves A High compression ratio the without Visual Changes (SUCH AS The size of My Mobile Phone Screen IS usually 110K, And it can reach 30k after compression).

Wayenjoy official websiteWay2enjoy2。way2enjoy supports uploading up to 50 images at a time, with a maximum of 50M.



一.Configuration environment

Python: Make sure there is a Python environment on your computer (or a Python environment if you have a Mac).

Way2enjoypy: Import Way2enjoypy

  pip install --upgrade Way2enjoypy

2. Apply for API key

Apply for an API key here:

一个 key You can compress 500 images per month for free, you can apply for multiple key。

三.Configuring the script and running

After downloading the script, you need to simply edit the script and fill in the application to the API key.

way2enjoypy.key = "Way2enjoy API key"

You can then put the script into the folder of the image you want to compress, and then enter the folder in the command line (terminal), execute the following command:


The generated file will be saved in a folder named way2enjoy in the current directory.

Run example and size comparison (there is a picture with the truth):

Fourth, support parameters

in v1.0.1 Parameter support is provided in the version. See the table below for details.:

Options Options Type Summary Example
No reference Compress all image files in the current folder
-f Image file Compress the specified single file -f /User/GcsSloop/demo.jpg
-d folder Compress all image files in the specified folder -d /User/GcsSloop/DemoDir
-w Integer number The width of the compressed image, the width is unchanged if not specified -w 300

Parameter priority:

  -f > -d > 无参

If specified -f Will only compress the specified file, even if it follows -d Will not compress the specified folder

 -w No conflict, can be used

-w It is used to specify that the width of the compressed image is highly adaptively scaled, so it can be used. (The options are not in order.): -w 300                              // Compress all image files in the current directory. After compression, the file span is 300.Specifies to compress a file with a file width of 300 after compression. -w 300 -f /User/GcsSloop/demo.jpg   // Specifies to compress a file with a file width of 300 after compression.

V. Auxiliary optimization

This step is not a necessary step, just to help you optimize some content:

Boot anywhere (for Linux and OS X platforms):

If you feel that you need to copy every Files are too cumbersome to compress to a directory. You can store the script in a folder and then add the folder to the environment variable to execute the script from anywhere (Linux and OS X platforms only) The command is directly the file name, no need to add python before, such as:

If the file name cannot be used directly, the file has no executable permissions. Use the following command to add executable permissions:

chmod +x

Boot from current directory (for OS X platform):: If it is cumbersome to enter a directory from the command line, on the Mac you can use the XtraFinder plugin to add a boot option from the current directory to your right button, launch the terminal directly in the current directory, and add it in XtraFinder To preferences. inside.

Update log

  • V1.0.0 supports compression of files in the current directory
  • V1.0.1 adds parameter support, supports compression of a single file, compresses all image files in the specified directory (excluding subdirectories), and compresses all image files in the current directory by default (excluding subdirectories)

About Me



Copyright (c) 2015 GcsSloop

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.


Image bulk compression script (Python)







No releases published


No packages published