Enable TinyPNG to Compress Images for XZ Pic

Publish: 2017-12-03 | Modify: 2017-12-03

XZ Pic (Xiao Z Image Hosting) is a simple image hosting program that is ready to use out of the box. It allows for quick uploading of images to a local server (or to Qiniu) and supports copying HTML and Markdown links with just one click, making it convenient and efficient.

TinyPNG has been introduced in the article "Optimize Your Website Images with TinyPNG". TinyPNG effectively compresses images, improving speed and saving bandwidth.

Registering for TinyPNG

To register for TinyPNG, visit their official website at https://tinypng.com/. Click on the top right corner and fill in your email to create an account. Once registered, you can obtain your API key from the management center and save it.

TinyPNG Registration

TinyPNG API Key

Installing XZ Pic Image Hosting

To install XZ Pic, download the latest version from master.zip and refer to the following articles for deployment instructions:

Enabling TinyPNG for XZ Pic

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

Enable TinyPNG in upload.php

Continue modifying the upload.php file and fill in your own TinyPNG API key around line 88. Save the file and upload an image to test it. You will notice a significant reduction in file size compared to local images.

TinyPNG API Key in upload.php

Other Notes

Enabling TinyPNG may slightly reduce image quality (which is generally not noticeable to the naked eye) and may slow down the upload speed (as it requires processing through the TinyPNG API). However, it significantly reduces file size. Users who require this feature can choose to enable it and are encouraged to provide feedback if any issues arise.

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


Comments