Enable TinyPNG for Image Compression in XZ Pic

xz pictinypng integrationimage compressionimage hostingapi key setup
Published·Modified·

XZ Pic (Xiao Z Image Bed) is a simple image hosting program that works out of the box, allowing you to quickly upload images to a local server or Qiniu. It supports one-click copying of HTML and Markdown links for convenience.

TinyPNG has been introduced in the article Using TinyPNG to Optimize Your Website Images. TinyPNG effectively compresses images, improving speed and saving traffic.

Register for TinyPNG

Visit the TinyPNG official website: https://tinypng.com/. Fill in your email at the top right corner to register an account. After successful registration, obtain your API key from the management center and save it.

TinyPNG Registration Interface

API Key Retrieval

Install XZ Pic Image Bed

Download the latest version of XZ Pic from master.zip and refer to the following articles for deployment:

Enable TinyPNG for XZ Pic

By default, XZ Pic does not have TinyPNG enabled. If you need to enable it, modify the upload.php file and uncomment the following code at the beginning:

Code Modification in upload.php

Continue modifying the upload.php file. Around line 88, enter your TinyPNG API key, save the file, and then test uploading an image. You can compare it with the local image; the file size will be significantly reduced.

Compression Result Comparison

Other Notes

After enabling TinyPNG, image quality may slightly decrease (usually imperceptible to the naked eye), and upload speed may slow down (due to processing via the TinyPNG API). However, the file size will be significantly reduced. Users who need this feature can choose to enable it. If you encounter any issues, please provide feedback promptly.

XZ Pic Source Code: https://github.com/helloxz/xz-pic