How Can We Help You?

Scaling

You can use image scaling to change the dimensions of your images by a certain factor. Unlike image resizing, image scaling takes simply a floating-point size factor to appropriately modify the image. For example, if you want your images to be 60% smaller, you would use the size value of 0.6.

<?php

/**
* Instantiate new `$picsmize` by calling a constructor
*/

$picsmize = new Picsmize('your-api-key');

/**
* Provide a publicly available image URL with fetch(string) method,
* and scale it down by 0.5
*/

$picsmize
->fetch('https://www.example.com/image.jpg')
->scale(0.5)
->toJSON(function ($response) {
if ($response['status'] == false) {
throw new Exception($response);
}

/**
* You'll find the full JSON metadata array within the `$response` variable.
* Remember to always check if the `status` property is set to `true`.
*/

if ($response['status'] == true) {
print ($response['output']['src']);
} else {
print ($response['message']);
}
});
curl -X POST \
https://api.picsmize.com/image/process \
-H "apikey: your-api-key" \
-H "content-type: application/json" \
-d '{
"img_url": "https://www.example.com/image.jpg",
"process": {
"scale": {
"size": 0.5
}
}
}'
									
										package main

										import (
											"fmt"

											"github.com/picsmize/picsmize-go"
										)

										func main() {

											pics, err := picsmize.Init("your-api-key")
											if err != nil {
												panic(err)
											}

											/**
											* Provide a publicly available image URL with fetch(string) method,
											* and scale it down by 0.5
											*/

											res, err := pics.Fetch("your-image-url").
												Scale(0.5).
												ToJSON()

											if err != nil {
												panic(err)
											}

											/**
											* You'll find the full JSON metadata within the `res` variable.
											*/

											fmt.Println(res)
										}
									
								
Given the input image 750px × 400px
Resizing An Image Online
Scale it down by 50% by setting "size" to 0.5
Compressor Photo
The resulting image is 50% of the input image: 375px × 200px