How I created an API to Resize and Compress Images Online

- Advertisement -

If you've ever needed to resize an image for a website, fast compression or even convert a PNG to JPG, you know how limited ready-made solutions can be - or how full of advertising and restrictions. As a developer and content creator, I decided to build my own own image resizing APIwith support for compression, format conversion and live preview - all within my WordPress environment.

In this article, I show you behind the scenes of this creation and how you can use or adapt something similar in your project.

API link: Online Image Resizer

Why did I create this API?

I needed a lightweight, functional and customizable solution for my own use and also for Criadix readers. Online tools don't always guarantee quality control, nor do they allow automated integrations with other workflows. By creating my own API:

  • I won total control over resizing
  • I was able to apply customized compression
  • I made it possible for conversion between formats (PNG ↔ JPG)
  • Added real-time visualization with on the front-end
  • And I was able to offer all this via WordPress plugin

How does the API work?

The core logic is in a PHP file that acts as a REST endpoint. It allows:

1. Uploading multiple images

With type validation (jpg, jpeg, png, webp, gif, bmp or tiff) and size limit.

2. Reading the original dimensions

The API obtains the width and height of each image uploaded and displays it to the user in the preview panel.

 

Clock and calendar, How to organize yourself effectively

Practical Tips for Getting Organized Efficiently

0
Practical Tips for Getting Organized Efficiently In an increasingly fast-paced world, time management has become an essential skill for personal and professional success. However, whether you're a student with too many tasks, an entrepreneur trying to...

 

3. Resizing by pixel or percentage

The user can choose between setting manual dimensions or maintaining the proportion automatically.

4. Adjustable compression

Using Imagick, I control the quality of the final image.

5. Format conversion

If the user sends PNG and opts for JPG output, the conversion is applied with transparent background smoothing.

6. Download in ZIP

If more than one image is imported, all the processed images are compressed into a single .zip for immediate download. Otherwise, the same image name will be compressed.

User experience (UX) on the front-end

As I value both the technical side and the user experience, the front-end delivers:

  • Live visualization with canvas
  • Simple and clean interface
  • Modal for enlarged view

Loading feedback and success with fetch and wp_ajax

How I implemented it in WordPress

Custom plugin

I've created a WordPress plugin called Image Process API. It registers an endpoint /wp-json/image-api/v1/process and offers it:

  • Security with nonce
  • Multiple file support
  • Option to use GD or Imagick depending on the server

Directory structure

  • /temp_uploads/ → received images
  • /final_images/ → converted and compressed images
  • /downloads/ → ready-made zip files

It also includes error logs for debugging and checking permissions on the local or remote server.

Next steps

Like any living project, I still want it:

  • Add batch resizing via remote URL
  • Create a dashboard to view usage statistics
  • Offer a widget for easy integration into other sites

Creating my own image resizing API was more than a technical challenge - it was a practical, customized solution for my day-to-day life as a creator and developer. And the best thing: I can now offer this tool in Criadix to help other users who also need to optimize images with more freedom and quality.

If you want to learn more about WordPress and PHP development, this type of project is a great starting point - and totally applicable to real life.

- Advertisement -
Cestaro
Cestaro
Hi, I'm Leandro Cestaro, creator of Criadix.com. I'm a data analyst, technology enthusiast and passionate about WordPress, artificial intelligence and digital content creation. I have solid experience in IT infrastructure and I'm always looking for creative solutions for complex environments, combining technique and practicality.As well as my professional side, I'm a father, married and believe in the power of knowledge to transform lives. At Criadix, I share experiences, tutorials and insights to help people explore the digital universe with more autonomy and inspiration. Welcome!

Related articles

Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Recent articles