Reverse-Engineering CDN Thumbnails: Recovering Full-Resolution Originals from Aliyun OSS, Tencent COS, and Qiniu URLs

 Every serious image pipeline serves thumbnails. The main image on a product page might be a 2,000px original, but the page loads a 200px version so it renders fast. When you're building an image collector, a design asset scraper, or a reverse image search tool, you constantly hit this wall: the URL in the HTML points at a thumbnail, not the original.


The naive fix — "just crawl the largest version on the page" — is unreliable. The robust fix is to understand how CDN image processing works, because Aliyun OSS, Tencent COS, and Qiniu all implement the same pattern: the original file stays untouched on storage, and thumbnails are generated on-the-fly by appending processing parameters to the URL query string.


That means the original URL is usually recoverable by stripping or rewriting those parameters. No re-download, no guessing.


## How Image-Processing CDNs Work


All three major Chinese cloud object stores (and most Western ones too — Cloudinary, imgix, Cloudflare Images) share the same architecture:


Original file: https://cdn.example.com/path/to/image.jpg

Thumbnail URL: https://cdn.example.com/path/to/image.jpg?x-oss-process=image/resize,w_200


The CDN edge node receives the request, reads the original from storage, applies the transformation (resize, crop, compress, watermark), caches the result, and serves it. The processing instruction lives entirely in the query string — the path to the original is unchanged.


So the recovery strategy has three steps:


1. Parse the URL and split it into base (scheme + host + path) and query.

2. Identify which CDN's parameter format the query matches.

3. Strip or rewrite the processing parameters to reconstruct the original URL.


## Aliyun OSS: x-oss-process


Aliyun's image processing is the x-oss-process parameter:


https://img.example.com/photo/2024/hero.jpg?x-oss-process=image/resize,w_300,h_300,m_fill


The pipeline syntax is image/<action>,<params> — and actions chain with /: image/resize,w_300/quality,q_75/format,jpg. Common actions:


- resize,w_200 / resize,w_200,h_200,m_fill — scale or crop-fill

- quality,q_75 — recompress

- format,jpg / format,webp — transcode (this one changes the actual content type!)

- watermark,text_... — overlay text or image watermarks

- blur,r_20,s_5 — gaussian blur


Recovery rule: if the query contains x-oss-process=image/..., strip the entire x-oss-process parameter. The URL without it is the original.


function stripAliyun(url) {

  const u = new URL(url);

  u.searchParams.delete('x-oss-process');

  return u.toString();

}


One caveat: some OSS buckets use the legacy image/resize style without x-oss-process= (rare now), and some use ?x-oss-process=image/resize,m_lfit,w_600,h_600 with multiple chained actions — still just one parameter to delete.


## Tencent COS: imageMogr2 and imageView2


Tencent COS has two parameter families:


imageMogr2 — the "advanced" pipeline, mirrors ImageMagick operations:


https://cdn.example.com/img/a.jpg?imageMogr2/thumbnail/!200x200r/quality/75


Actions are path-style segments after imageMogr2/:


- thumbnail/!200x200r — thumbnail with aspect-ratio preservation

- thumbnail/200x — width 200, auto height

- quality/75 — recompress

- strip — remove EXIF

- format/webp — transcode


imageView2 — the simpler preset API:


https://cdn.example.com/img/a.jpg?imageView2/2/w/200/h/200


Modes 0–5 cover crop/scale combinations: imageView2/1/w/200/h/200 (crop), imageView2/2/w/200 (scale), imageView2/3/w/200 (shrink only).


Recovery rule: delete the imageMogr2/... or imageView2/... path segment from the query string. Note these are query string segments, not standard key=value pairs — they sit in the raw query as ?imageMogr2/thumbnail/!200x200r/quality/75. You have to manipulate the raw query string, not searchParams, because there's no = sign:


function stripTencent(url) {

  const u = new URL(url);

  const q = u.search.replace(/^[?&]/, '').split('&')

    .filter(seg => !seg.startsWith('imageMogr2/') && !seg.startsWith('imageView2/'))

    .join('&');

  u.search = q;

  return u.toString();

}


COS also supports ?imageMogr2/thumbnail/!200x200r/quality/75&x-cos-process=... in newer configurations — handle imageMogr2 and imageView2 first; that covers 99% of real thumbnails.


## Qiniu: imageView2 and imageMogr2


Qiniu uses the same two-family design as Tencent (both borrowed from the same convention):


https://cdn.example.com/asset/img.png?imageView2/1/w/200/h/200

https://cdn.example.com/asset/img.png?imageMogr2/thumbnail/!200x200r/quality/80


Plus a few Qiniu-specific extras:


- ?imageView2/2/w/200/format/webp — transcode

- ?imageMogr2/auto-orient — EXIF orientation fix

- ?imageView2/0/w/200/h/200 — mode 0, fit within box


Recovery rule: identical to Tencent — strip imageView2/... and imageMogr2/... segments.


## The Edge Cases That Bite


1. Format transcoding: ?x-oss-process=image/format,webp or imageMogr2/format/webp means the thumbnail is actually WebP while the original is JPEG/PNG. Stripping the parameter recovers the original URL and its correct extension — but only if the URL path still ends in .jpg. If the CDN rewrites the extension (some do: hero.jpg?format,webp serves WebP with .jpg in the path), the content-type header will lie. Always strip the param; verify with a HEAD request when correctness matters.


2. Chained params mixed with cache busters: real URLs look like hero.jpg?x-oss-process=image/resize,w_300&t=1234567. Delete only the processing params; keep cache-busters and signature tokens (?sign=..., ?Expires=...&Signature=...) — deleting signed tokens will 403.


3. Style presets (OSS): OSS allows named styles: ?x-oss-process=style/thumb_200. The style/ action is opaque — you can't reverse it from the URL alone; you need the bucket's style definition. If style/ appears, strip it anyway (the style name is a processing alias, and the original path still points at the full file).


4. CDN edge domains with path prefixes: some setups route cdn.example.com/resize/w_200/path/to/img.jpg (path-style processing, e.g. some imgproxy/Thumbor deployments). No query parameter to strip — you must know the prefix convention. Most OSS/COS/Qiniu setups don't do this, but a collector should detect and report unknown shapes rather than silently mangling URLs.


## A Practical Recovery Pipeline


const CDN_RULES = [

  { name: 'aliyun', test: p => p.has('x-oss-process') && p.get('x-oss-process').startsWith('image/'),

    strip: u => { u.searchParams.delete('x-oss-process'); return u; } },

  { name: 'tencent/qiniu', test: p => p.has('imageMogr2') || p.has('imageView2'),

    strip: stripTencent },

];


function recoverOriginal(rawUrl) {

  const u = new URL(rawUrl);

  for (const rule of CDN_RULES) {

    if (rule.test(u.searchParams)) return rule.strip(u).toString();

  }

  return null;

}


The same function powers both bulk de-duplication (recover → compare hashes of originals, not thumbnails) and "download the largest available version" logic.


## Why This Belongs in a Browser Extension


This recovery logic is pure URL string manipulation — trivially fast, zero network calls, and it works offline on any page the user visits. That's exactly the kind of capability that should live in a local collector rather than a server:


- No privacy leak: the URL transformation happens on-device; you never upload the page or the URL list.

- Deterministic and testable: given the same thumbnail URL, you always get the same original URL.

- Composable: recovery composes with perceptual hashing (compare recovered originals, not downscaled thumbs), with classification (a 4K original sorts into the Ultra HD bucket, its 200px thumbnail into the thumbnail bucket), and with ZIP export (you export the highest-fidelity file you can recover).


## OmniPic: Full-Resolution Recovery, Built In


CDN recovery in production is more than a one-liner: you need rule tables for each provider, handling for style presets and cache-busters, HEAD-request verification for format-transcoded thumbnails, and graceful fallback when a URL shape is unknown.


OmniPic AI Studio Pro ships that pipeline ready to use:


- CDN original restoration — automatically recovers full-resolution originals from Aliyun OSS (x-oss-process), Tencent COS (imageMogr2 / imageView2), and Qiniu (imageView2 / imageMogr2) thumbnails; verified with HEAD requests, falls back gracefully on unknown shapes

- pHash visual deduplication — 64-bit perceptual hashing with a BK-tree index; near-duplicates are filtered even at 2,000+ images

- On-device AI reverse image search — MobileNet 1024-dim features with WebGPU acceleration

- Smart auto-classification — 4K Ultra HD / 1080P HD / medium / thumbnail buckets, so recovered originals sort correctly

- Streaming ZIP export — 2,000+ images in one archive with constant memory; the tab never freezes

- Eagle/Billfish integration — exports with complete metadata into your design library format

- 100% local processing — your images and browsing activity never leave your device


## Get Started


OmniPic AI Studio Pro is available on all three major browser extension stores:


- Chrome: Chrome Web Store (https://chromewebstore.google.com/detail/omnipic-studio-pro/cokoeaaaglgcljahaffjeijomhmkljlc)

- Edge: Microsoft Edge Add-ons

- Firefox: Firefox Add-ons


The next time you stare at a 200px thumbnail and wish you had the 4000px original, remember: the original was there all along — hiding in plain sight behind a query string. The parameter isn't the image's identity; it's just the resize instruction.

评论

此博客中的热门博文

Running AI in the Browser: WebGPU-Accelerated MobileNet Feature Extraction for Real-Time Image Search

Why Image Scrapers Silently Fail: CORS, Tainted Canvases, and Blob URLs

Why Your Image Crawler Collects Blur Placeholders (and Misses the Images Hiding in CSS)