# IPFS Image Optimizer

The 4EVERLAND Optimizer is a real-time dynamic image optimization service that automatically optimizes images to accelerate image transmission speed and save bandwidth.&#x20;

Due to the inability of CID to directly represent file types, when using a dedicated gateway for trimming, it is necessary to include the additional parameter '`optimizer=image`' in the request.

## API Usage:&#x20;

Request Format: \
`{yourGateway}.4everland.link/ipfs/{cid}?{parameter}={value}&optimizer=image`

Example:&#x20;

To crop the CID image `bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty` to a width of 150, with an aspect ratio of 2:3, the API request would be: \
\
[`https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?width=150&aspect_ratio=2:3&optimizer=image`](https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?width=150\&aspect_ratio=2:3\&optimizer=image)

Request Result:&#x20;

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?width=150&#x26;aspect_ratio=2:3&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

Original Image Before Processing:

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Optimizer does not support the use of custom Bucket gateways at this time.
{% endhint %}

## Parameters

### Width

***Parameter:*** width    ***Units:*** Pixels   ***Default:*** auto

Resize the output image to the given width maintaining the current aspect ratio.

Aspect Ratio Crop has priority over the Width or Height commands. If the Aspect Ratio Crop is defined in the query and is not set to auto, it will be applied first.

{% hint style="info" %}
Aspect Ratio Crop has priority over the Width or Height commands. If the Aspect Ratio Crop is defined in the query and is not set to auto, it will be applied first.
{% endhint %}

?width=250

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?width=250&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?width=100

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?width=100&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Height

***Parameter:*** height   &#x20;**&#x20;*****Units**:* Pixels    ***Default:*** auto

Resize the output image to the given width maintaining the current aspect ratio.

?height=250

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?height=250&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?height=100

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?height=100&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Aspect Ratio Crop

***Parameter:*** aspect\_ratio     ***Units:*** Pixels    ***Default:*** auto

Crop the output image to match the given aspect ratio. The default origin point (gravity) is positioned on the center of the image.

?aspect\_ratio=1:1

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?aspect_ratio=1:1&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?aspect\_ratio=2:1

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?aspect_ratio=2:1&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Quality

***Parameter:*** quality    ***Units:*** Percent   ***Range:*** 0-100    ***Default:*** 85

Determines the compression level of the resulting image with 100 being the lowest level of compression and 0 being the highest. Higher compression means smaller files, but might visually degrade the image (e.g. JPEG compression under 70 tends to produce visible artefacts.

?quality=10

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?quality=10&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?quality=100

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?quality=100&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Sharpen

***Parameter:*** sharpen   ***Units:*** Boolean    ***Default:*** false

Sharpen the output image.

?sharpen=true

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty??sharpen=true&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?sharpen=false

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?sharpen=false&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Blur

***Parameter:*** blur    ***Units:*** Number    ***Range:*** 0-100    ***Default:*** 0

Blur the output image.

?blur=10

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?blur=10&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?blur=30

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?blur=30&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Crop

***Parameter:*** crop   ***Units:*** Pixels    ***Format 1:*** width,height    ***Format 2:*** width,height,x,y

Crop the output image to the given width and height. Two formats are accepted. Format 1 one only includes the width and height of the crop. Format 2 also includes the X and Y position where the crop should start. Image resizing with the width and height parameters is processed after the crop and the resized measurements apply.

If only width and height are given, the Crop Gravity parameter will be used.

?crop=180,60

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?crop=180,60&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?crop=180,60,10,10

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?crop=180,60,10,10&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Crop Gravity

***Parameter:*** crop\_gravity   ***Default:*** center

Values: center, forget, east, north, south, west, northeast, northwest, southeast, southwest

Set the gravity of the crop operation. This is used with the Format 1 cropping only and snaps the crop to the selected position.

?crop=180,60\&crop\_gravity=center

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?crop=180,60&#x26;crop_gravity=center&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?crop=180,60\&crop\_gravity=northeast

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?crop=180,60&#x26;crop_gravity=northeast&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Flip

***Parameter:*** flip    ***Units:*** Boolean   ***Default:*** false

Flip the output image vertically.

?flip=true

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?flip=true&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?flip=false

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?flip=false&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Flop

***Parameter:*** flop    ***Units:*** Boolean    ***Default:*** false

Flip the output image horizontally.

?flop=true

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?flop=true&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?flop=false

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?flop=false&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Brightness

***Parameter:*** brightness    ***Units:*** Number    ***Range:*** -100-100    ***Default:*** 0

Adjusts the brightness of the output image. This can either brighten or darker the image.

?brightness=80

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?brightness=80&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?brightness=-20

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?brightness=-20&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Saturation

***Parameter:*** saturation    ***Units:*** Number    ***Range:*** -100 - 100    ***Default:*** 0

Adjusts the saturation of the output image. Use -100 for grayscale.

?saturation=80

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?saturation=80&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?saturation=-20

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?saturation=-20&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Hue

***Parameter:*** hue    ***Units:*** Number    ***Range:*** 0-100    ***Default:*** 0

Adjusts the hue of the output image by rotating the color wheel. The default value of 0 is the base color and increasing the value modulates to the next color for each 33 change.

?hue=80

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?hue=80&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?hue=20

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?hue=20&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Contrast

***Parameter:*** contrast    ***Units:*** Number    ***Range:*** -100 - 100    ***Default:*** 0

Adjusts the contrast of the output image.

?contrast=-20

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?contrast=-20&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?contrast=80

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?contrast=80&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Automatic Optimization

***Parameter:*** auto\_optimize ***Units:*** String    ***Values:*** low,medium,high    ***Default:*** none

Automatically enhance the output image with multiple levels of optimizations. With high, sharpening is also applied automatically.

?auto\_optimize=low

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?auto_optimize=low&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?auto\_optimize=high

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?auto_optimize=high&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

### Sepia

***Parameter:*** sepia ***Units:*** Integer ***Values:*** 0 - 100 ***Default:*** 0

Changes the image color to the sepia color scheme.

?sepia=20

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?sepia=20&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>

?sepia=80

<figure><img src="https://aaaaaaa.4everland.link/ipfs/bafkreiebfj3ivxh7utbetgtettfaob7mze6xnd55evijdyfpdcbz6wlbty?sepia=80&#x26;optimizer=image" alt=""><figcaption></figcaption></figure>
