# Image format converter JPG PNG WEBP (`akash9078/image-format-converter`)

Effortlessly convert and optimize images between formats like JPEG, PNG, WebP, AVIF, and more. Maintain high quality while reducing file size for faster websites, stunning social media visuals, and print-ready graphics.

- **URL**: https://beta-securitybyobscurity.apify.com/akash9078/image-format-converter.md
- **Developed by:** [Akash Kumar Naik](https://beta-securitybyobscurity.apify.com/akash9078) (community)
- **Categories:** Developer tools, Other, Automation
- **Stats:** 3 total users, 3 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

$25.00 / 1,000 results

This Actor is paid per result. You are not charged for the Apify platform usage, but only a fixed price for dataset items the Actor outputs.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-result

# README

## 🚀 Ultimate Image Converter & Optimizer for Web & Print

Transform and optimize your images effortlessly with this powerful Apify Actor. Convert between popular formats like JPEG, PNG, WebP, AVIF, and more, ensuring your visuals are perfectly optimized for any platform – from blazing-fast websites to high-quality print.

### ✨ Key Features & Benefits

- **Universal Format Conversion**:
  - **Input Formats**: Supports a wide range of common image input formats including JPEG, PNG, WebP, GIF, TIFF, BMP, HEIC, AVIF, and various RAW camera formats.
  - **Output Formats**: Convert to optimized formats such as JPEG, PNG, WebP, AVIF, GIF, TIFF, BMP, and HEIF.
    Ideal for web developers, designers, and content creators.
- **Advanced Image Optimization**: Reduce file sizes without compromising quality. Perfect for improving website loading speeds and SEO performance.
- **Customizable Quality Control**: Fine-tune image compression (1-100) to meet your exact needs, balancing visual fidelity with file size efficiency.
- **High-Performance Processing**: Leverage cutting-edge technology for rapid image transformations, handling large volumes with ease.
- **Automated Workflow Integration**: Designed as an Apify Actor, it integrates smoothly into your automated data pipelines and web scraping projects.

### 💡 Use Cases

- **Website Optimization**: Convert large images to WebP or AVIF for faster page loads and better search engine rankings.
- **E-commerce Product Images**: Standardize product photo formats and optimize them for online stores.
- **Content Management**: Prepare images for blogs, articles, and social media with optimal dimensions and quality.
- **Batch Image Processing**: Automate the conversion of entire image libraries for various uses.
- **API Integration**: Build custom applications that require on-demand image format conversion.

### 🚀 Quick Start

#### How to Use

1. **Input Image URL**: Provide the direct URL of the image you want to convert.
2. **Select Output Format**: Choose your desired output format (e.g., `webp`, `jpeg`, `png`).
3. **Adjust Quality (Optional)**: Set the compression quality from 1 to 100 for formats like JPEG, WebP, and AVIF.

#### Example Input

```json
{
  "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/640px-PNG_transparency_demonstration_1.png",
  "outputFormat": "webp",
  "quality": 85
}
```

### 📊 Output Data

Each successful conversion provides a detailed record, including:

- **`originalUrl`**: The URL of the original image.
- **`outputUrl`**: The URL of the converted image, hosted on Apify Key-Value Store.
- **`originalFormat`**: The detected format of the input image.
- **`targetFormat`**: The format to which the image was converted.
- **`originalSize`**: Size of the original image in bytes.
- **`convertedSize`**: Size of the converted image in bytes.
- **`compressionRatio`**: Percentage change in file size after conversion.
- **`status`**: Indicates `success` or `error` for the conversion.
- **`error`**: (If applicable) Details about any conversion failures.

```json
{
  "originalUrl": "https://example.com/photo.jpg",
  "originalFilename": "photo.jpg",
  "originalFormat": "JPEG",
  "originalSize": 2457600,
  "targetFormat": "WEBP",
  "outputFilename": "photo.webp",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/.../records/photo.webp",
  "convertedSize": 1843200,
  "compressionRatio": "25.00%",
  "compressionSavings": "0.59MB saved",
  "status": "success",
  "processingTime": 1250,
  "retryCount": 0
}
```

# Actor input Schema

## `imageUrl` (type: `string`):

The URL of the image to convert. Supports a wide range of common image input formats including JPEG, PNG, WebP, GIF, TIFF, BMP, HEIC, AVIF, and various RAW camera formats.

## `outputFormat` (type: `string`):

The desired output format for the image.

## `quality` (type: `integer`):

Quality of the output image (1-100). Applicable for lossy formats like JPEG, WebP, AVIF.

## Actor input object example

```json
{
  "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/640px-PNG_transparency_demonstration_1.png",
  "outputFormat": "webp",
  "quality": 90
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/640px-PNG_transparency_demonstration_1.png",
    "outputFormat": "webp",
    "quality": 90
};

// Run the Actor and wait for it to finish
const run = await client.actor("akash9078/image-format-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/640px-PNG_transparency_demonstration_1.png",
    "outputFormat": "webp",
    "quality": 90,
}

# Run the Actor and wait for it to finish
run = client.actor("akash9078/image-format-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/640px-PNG_transparency_demonstration_1.png",
  "outputFormat": "webp",
  "quality": 90
}' |
apify call akash9078/image-format-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=akash9078/image-format-converter",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Image format converter JPG PNG WEBP",
        "description": "Effortlessly convert and optimize images between formats like JPEG, PNG, WebP, AVIF, and more. Maintain high quality while reducing file size for faster websites, stunning social media visuals, and print-ready graphics.",
        "version": "1.2",
        "x-build-id": "GL3mB5BlxExGdDNux"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/akash9078~image-format-converter/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-akash9078-image-format-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/akash9078~image-format-converter/runs": {
            "post": {
                "operationId": "runs-sync-akash9078-image-format-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/akash9078~image-format-converter/run-sync": {
            "post": {
                "operationId": "run-sync-akash9078-image-format-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "imageUrl",
                    "outputFormat"
                ],
                "properties": {
                    "imageUrl": {
                        "title": "Image URL",
                        "pattern": "^https?:\\/\\/[^\\s/$.?#].[^\\s]*$",
                        "type": "string",
                        "description": "The URL of the image to convert. Supports a wide range of common image input formats including JPEG, PNG, WebP, GIF, TIFF, BMP, HEIC, AVIF, and various RAW camera formats."
                    },
                    "outputFormat": {
                        "title": "Output Format",
                        "enum": [
                            "jpeg",
                            "jpg",
                            "png",
                            "webp",
                            "gif",
                            "avif",
                            "tiff",
                            "bmp",
                            "heif"
                        ],
                        "type": "string",
                        "description": "The desired output format for the image."
                    },
                    "quality": {
                        "title": "Quality",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Quality of the output image (1-100). Applicable for lossy formats like JPEG, WebP, AVIF.",
                        "default": 90
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
