{"id":13649,"date":"2025-12-03T14:34:23","date_gmt":"2025-12-03T12:34:23","guid":{"rendered":"https:\/\/shortpixel.com/blog\/?p=13649"},"modified":"2025-12-03T14:34:24","modified_gmt":"2025-12-03T12:34:24","slug":"image-upscaling-apis-with-practical-php-examples","status":"publish","type":"post","link":"https:\/\/shortpixel.com\/blog\/image-upscaling-apis-with-practical-php-examples\/","title":{"rendered":"Image Upscaling APIs (With Practical PHP Examples)"},"content":{"rendered":"\n<p>Image upscaling has come a long way. Instead of stretching pixels or relying on browser-side tricks, modern APIs use machine learning to increase resolution while keeping edges sharp and noise under control. <\/p>\n\n\n\n<p>Whether you&#8217;re building a photo-heavy application, an ecommerce store, or a media tool, an upscaling API gives you consistent results without maintaining your own image-processing stack.<\/p>\n\n\n\n<p>In this post, we\u2019ll look at how image upscaling works, what to consider when choosing an API, and how to implement upscaling in PHP. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ShortPixel<\/h2>\n\n\n\n<p>ShortPixel is widely known in the website world, primarily for making images load faster.<\/p>\n\n\n\n<p>It provides AI-based enlargement through its <a href=\"https:\/\/shortpixel.com\/api-docs\" data-type=\"link\" data-id=\"https:\/\/shortpixel.com\/api-docs\">Reducer API<\/a>. It supports 2x, 3x, and 4x upscaling along with compression and optional WebP or AVIF conversion.<\/p>\n\n\n\n<p><strong>PHP example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$apiKey = \"&lt;&lt;YOUR_SHORTPIXEL_API_KEY&gt;&gt;\";\n$imageUrl = \"https:\/\/example.com\/photo.png\"; \n\n$data = json_encode(&#91;\n    \"key\" =&gt; $apiKey, \n    \"plugin_version\" =&gt; \"MYAPP\", \n    \"urllist\" =&gt; &#91;$imageUrl], \n    \"upscale\" =&gt; 4, \n    \"lossy\" =&gt; 1, \n    \"wait\" =&gt; 30, \n]);\n\n$ch = curl_init(\"https:\/\/api.shortpixel.com\/v2\/reducer.php\");\n\ncurl_setopt_array($ch, &#91;\n    CURLOPT_POST =&gt; true,\n    CURLOPT_RETURNTRANSFER =&gt; true,\n    CURLOPT_HTTPHEADER =&gt; &#91;\n        \"Content-Type: application\/json\",\n        \"Accept: application\/json\"\n    ],\n    CURLOPT_POSTFIELDS =&gt; $data\n]);\n\n$response = curl_exec($ch);\ncurl_close($ch);\n\necho $response;\n?&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Pixelcut Upscaler API<\/h2>\n\n\n\n<p>Pixelcut offers a fast AI upscaling service aimed at ecommerce visuals and product photography. It supports 2x and 4x enlargement and keeps the API simple by focusing only on enhancement and background cleanup.<\/p>\n\n\n\n<p><strong>PHP example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n  CURLOPT_URL =&gt; 'https:\/\/api.developer.pixelcut.ai\/v1\/upscale',\n  CURLOPT_RETURNTRANSFER =&gt; true,\n  CURLOPT_ENCODING =&gt; '',\n  CURLOPT_MAXREDIRS =&gt; 10,\n  CURLOPT_TIMEOUT =&gt; 0,\n  CURLOPT_FOLLOWLOCATION =&gt; true,\n  CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,\n  CURLOPT_CUSTOMREQUEST =&gt; 'POST',\n  CURLOPT_POSTFIELDS =&gt;'{\n  \"image_url\": \"https:\/\/cdn3.pixelcut.app\/product.jpg\",\n  \"scale\": 2\n}',\n  CURLOPT_HTTPHEADER =&gt; array(\n    'Content-Type: application\/json',\n    'Accept: application\/json',\n    'X-API-KEY: &lt;API_KEY_VALUE&gt;'\n  ),\n));\n\n$response = curl_exec($curl);\n\ncurl_close($curl);\necho $response;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">ImgUpscaler API<\/h2>\n\n\n\n<p>ImgUpscaler provides enlargement up to 8x depending on the model selected. The service is lightweight and designed for quick integrations with simple JSON responses.<\/p>\n\n\n\n<p><strong>PHP example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$url = \"https:\/\/imageupscaler.com\/api\/update_image.php?method=upscale-image-4x\";\n$localImagePath = '\/path\/to\/your\/photo.png';\n\n$ch = curl_init($url);\n$cfile = new CURLFile($localImagePath, 'image\/png', 'photo.png');\n\ncurl_setopt_array($ch, &#91;\n    CURLOPT_POST =&gt; true,\n    CURLOPT_RETURNTRANSFER =&gt; true,\n    CURLOPT_HTTPHEADER =&gt; &#91;\n        \"Authorization: Bearer &lt;&lt;API_KEY&gt;&gt;\" \n    ],\n    CURLOPT_POSTFIELDS =&gt; &#91;\n        'file_image' =&gt; $cfile\n    ]\n]);\n\n$response = curl_exec($ch);\n\nif (curl_errno($ch)) {\n    echo 'Error:' . curl_error($ch);\n}\n\ncurl_close($ch);\n\necho $response;\n?&gt;\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">DeepAI Super Resolution API<\/h2>\n\n\n\n<p>DeepAI offers a general purpose super resolution model that enlarges images while keeping edges clean. It uses a straightforward REST interface and returns a new file URL after processing.<\/p>\n\n\n\n<p><strong>PHP example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nrequire 'vendor\/autoload.php'; \/\/ Ensure you have Guzzle installed (composer require guzzlehttp\/guzzle)\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Psr7\\Utils;\n\n$client = new Client();\n$headers = &#91;\n    'api-key' =&gt; 'YOUR_API_KEY'\n];\n$options = &#91;\n    'multipart' =&gt; &#91;\n        &#91;\n            'name'     =&gt; 'image',\n            'contents' =&gt; 'YOUR_IMAGE_URL'\n        ],\n    ]\n];\n$request = new GuzzleHttp\\Psr7\\Request('POST', 'https:\/\/api.deepai.org\/api\/torch-srgan', $headers);\ntry {\n    $res = $client-&gt;sendAsync($request, $options)-&gt;wait();\n    echo $res-&gt;getBody();\n} catch (Exception $e) {\n    echo 'Error: ' . $e-&gt;getMessage();\n}\n?&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Replicate AI Upscalers<\/h2>\n\n\n\n<p>Replicate hosts a wide range of community and commercial <a href=\"https:\/\/replicate.com\/collections\/super-resolution\" data-type=\"link\" data-id=\"https:\/\/replicate.com\/collections\/super-resolution\" target=\"_blank\" rel=\"noopener\">super-resolution models<\/a> such as Real-ESRGAN. Each model has its own endpoint, but the request pattern is consistent.<\/p>\n\n\n\n<p><strong>PHP example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$apiKey = \"&lt;&lt;YOUR_REPLICATE_API_KEY&gt;&gt;\";\n$modelVersion = \"&lt;&lt;SUPER_RESOLUTION_MODEL_VERSION_ID&gt;&gt;\";\n$imageUrl = \"https:\/\/example.com\/input_image.jpg\"; \n\n$data = json_encode(&#91;\n    \"version\" =&gt; $modelVersion,\n    \"input\" =&gt; &#91;\n        \"image\" =&gt; $imageUrl,\n        \"scale\" =&gt; 4\n    ]\n]);\n\n$ch = curl_init(\"https:\/\/api.replicate.com\/v1\/predictions\");\n\ncurl_setopt_array($ch, &#91;\n    CURLOPT_POST =&gt; true,\n    CURLOPT_RETURNTRANSFER =&gt; true,\n    CURLOPT_HTTPHEADER =&gt; &#91;\n        \"Authorization: Token \" . $apiKey,\n        \"Content-Type: application\/json\",\n        \"Prefer: wait=60\" \n    ],\n    CURLOPT_POSTFIELDS =&gt; $data\n]);\n\n$response = curl_exec($ch);\ncurl_close($ch);\n\necho $response;\n?&gt;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Final notes<\/h2>\n\n\n\n<p>These APIs share a similar structure. Send an image URL or uploaded file, specify an upscaling factor, and handle the returned download link. <\/p>\n\n\n\n<p>The differences are usually in speed, maximum scale, and pricing. If consistency and automation matter more than raw enlargement numbers, any of the above services will get the job done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Image upscaling has come a long way. Instead of stretching pixels or relying on browser-side tricks, modern APIs use machine learning to increase resolution while keeping edges sharp and noise under control. Whether you&#8217;re building a photo-heavy application, an ecommerce store, or a media tool, an upscaling API gives you consistent results without maintaining your [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":13892,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-13649","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-image-optimization"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/posts\/13649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/comments?post=13649"}],"version-history":[{"count":18,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/posts\/13649\/revisions"}],"predecessor-version":[{"id":13921,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/posts\/13649\/revisions\/13921"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/media\/13892"}],"wp:attachment":[{"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/media?parent=13649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/categories?post=13649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shortpixel.com\/blog\/wp-json\/wp\/v2\/tags?post=13649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}