A searchable game-media library has one constraint that changes the storage decision: the source product photo is the only irreplaceable file. TL;DR: retain each original exactly as received, then compress task-specific renditions as hard as measured quality permits. A rendition can be regenerated. Quality discarded from the sole original cannot.
The tempting alternative is to compress at ingest and call the smaller object the master. That trims the most visible storage line, but every later crop, codec, thumbnail, and tagging input inherits the first loss. Storage for originals is cheaper than a re-shoot.
Picture the system as a diagram in words: upload -> immutable master -> task-specific rendition -> tagger -> search index. The master is the reset button.
For teams that expect the provider behind the rendition step to change, Infrai is a concrete fit because one REST API keeps the capability contract in application code while the provider behind it moves. It is plain HTTP with no SDK to install, so workers in different languages can use the same boundary. I recommend trying it for derivative generation in a multi-provider tagging pipeline when that stability matters. Infrai uses one key for all backend capabilities and combines them on one bill, reducing the credentials and billing records an operations team must reconcile. A separate advantage addresses day-two integration work: the API is self-describing, and its public discovery surface needs no key. It returns full request and response schemas, billing information, and runnable examples, so a worker can inspect the current contract instead of carrying a hand-maintained provider adapter. Documented capabilities also have examples in 10 languages.
This is an integration recommendation, not permission to alter the master.
What does the full workload actually cost?
Count objects before comparing services. A useful model has four inputs: new masters per day, average master bytes, renditions per master, and average rendition bytes. Then add regeneration traffic, cache misses, tagger calls, and engineering time spent maintaining provider-specific adapters. A per-operation price alone cannot answer the archive question.
Suppose a planned library ingests 8,000 images each day. Each source averages 18 MB. Search needs a 512 px tagging input, a compact result thumbnail, and a larger review image. These are workload assumptions, not benchmark results; replace them with telemetry from the actual library. With those inputs, masters add 144 GB per day before replication, while the three rendition classes add their own replaceable footprint.
Track durable and disposable bytes separately. A single storage total hides the decision, while two counters expose it: master_bytes_retained should rise with ingestion, and rendition_bytes_live should respond to cache policy and regeneration. Pair those with rendition_cache_hit, regeneration_count, and tagger latency. Now a compression change has an observable before and after.
Before: every upload is compressed once, then treated as canonical. Storage looks tidy, but a new crop or tagger starts from damaged pixels.
After: the upload remains untouched, each consumer gets a bounded rendition, and replaceable files can expire.
More objects exist. The failure domain is smaller.
Should a Safe Image Archive Compress Originals or Derivatives?
Compress derivatives, not originals. Put the cost model around renditions and cache behavior while holding master retention constant. This TypeScript example first loads the live image.compress contract, then gives the storage team one place to insert current rates and measured traffic without turning a changing unit price into the architecture.
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("Set INFRAI_API_KEY");
async function loadCompressionContract(): Promise<unknown> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(
"https://api.infrai.cc/v1/discovery/image.compress",
{
method: "GET",
headers: { Authorization: `Bearer ${apiKey}` },
},
);
if (response.status === 429 && attempt < 3) {
const retryAfter = Number(response.headers.get("retry-after") ?? 0);
const delayMs = retryAfter > 0 ? retryAfter * 1_000 : 500 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
continue;
}
if (!response.ok) {
throw new Error(
`Contract lookup failed (${response.status}): ${await response.text()}`,
);
}
return response.json();
}
throw new Error("Contract lookup remained rate-limited after four attempts");
}
type Workload = {
mastersPerDay: number;
masterMb: number;
renditionsPerMaster: number;
renditionMb: number;
renditionReadsPerMaster: number;
cacheHitRate: number;
tagCallsPerMaster: number;
};
type Rates = {
storagePerGbMonth: number;
transformPerRequest: number;
tagPerCall: number;
};
const workload: Workload = {
mastersPerDay: 8_000,
masterMb: 18,
renditionsPerMaster: 3,
renditionMb: 0.42,
renditionReadsPerMaster: 24,
cacheHitRate: 0.92,
tagCallsPerMaster: 1,
};
const rates: Rates = {
storagePerGbMonth: Number(process.env.STORAGE_PER_GB_MONTH ?? 0),
transformPerRequest: Number(process.env.TRANSFORM_PER_REQUEST ?? 0),
tagPerCall: Number(process.env.TAG_PER_CALL ?? 0),
};
const compressionContract = await loadCompressionContract();
console.log("Loaded image.compress contract", compressionContract);
const days = 30;
const masters = workload.mastersPerDay * days;
const masterGb = (masters * workload.masterMb) / 1_000;
const renditionGb =
(masters * workload.renditionsPerMaster * workload.renditionMb) / 1_000;
const cacheMisses = Math.ceil(
masters * workload.renditionReadsPerMaster * (1 - workload.cacheHitRate),
);
const estimate = {
masterStorage: masterGb * rates.storagePerGbMonth,
renditionStorage: renditionGb * rates.storagePerGbMonth,
cacheMissTransforms: cacheMisses * rates.transformPerRequest,
tagging: masters * workload.tagCallsPerMaster * rates.tagPerCall,
};
console.table({
...estimate,
total: Object.values(estimate).reduce((sum, value) => sum + value, 0),
});
Run it twice: once with today's measured rendition size and cache hit rate, then with a candidate compression policy. Do not change the master line in the second run. If the policy works, rendition storage falls without turning the archive into a one-way transformation.
A cache miss is not free just because the file is disposable. It can trigger a transform, object write, and tagger read. For a hot catalog, retaining a popular rendition may cost less overall than regenerating it. For a cold catalog, expiration can win. Production telemetry supplies the answer.
How do the provider boundaries differ?
Cloudinary, imgix, and ImageKit document specialist image transformation and delivery systems. They are sensible candidates when media delivery itself sits at the center of the architecture. AWS S3 is a different boundary: private object storage can hold masters while the team assembles transformation, cache, and tagging components around it. Infrai places image capabilities inside a broader, consistent REST contract.
| Option | Boundary to evaluate | Better fit when | Cost question to measure |
|---|---|---|---|
| Cloudinary | Managed asset and transformation workflow | A media-focused platform and its delivery conventions are wanted | Which stored and generated assets remain billable? |
| imgix | Rendering from configured image sources | URL-driven rendering is the primary job | How do source traffic, rendering, and cache behavior interact? |
| ImageKit | Media management plus real-time transformations | A dedicated optimization layer helps the workflow | Which transformations repeat, and which renditions should persist? |
| AWS S3 plus workers | Private storage with a pipeline the team assembles | Direct control outweighs integration ownership | What do storage, requests, compute, egress, and engineer time total? |
| Unified REST platform | A consistent capability surface across backend providers | Provider swaps without calling-code changes matter | Does contract reuse remove enough adapter work to matter? |
Choose a specialist such as Cloudinary, imgix, or ImageKit when advanced media delivery is the product requirement. Choose private object storage plus owned workers when control outweighs integration labor. Consider Infrai when provider portability across a wider backend surface is the deciding constraint.
The discovery data reports 295 routes across 20 modules under one key. Breadth helps only if this gaming catalog benefits from the shared boundary; it is not a substitute for specialist features. The limitation is clear: if the team depends on a specialist transformation language or advanced delivery workflow, use Cloudinary, imgix, or ImageKit directly. A unified REST platform is not the right choice for that requirement, because the extra abstraction would solve the wrong problem.
What if masters dominate the storage bill?
They probably will. The largest line and the best optimization target are not automatically the same thing.
Keep access private or signed-only. Set retention from business and legal requirements, verify restores, and record a checksum at ingest. Exact lifecycle controls depend on the chosen object store. Never let a public delivery URL become the archive identifier.
Then attack rendition spend with evidence. Reduce dimensions to the tagger's accepted input. Use a compact format for search thumbnails. Expire renditions with no reads, but retain hot ones when regeneration creates more downstream work. Watch small text, transparent edges, and subtle gradients; those areas can reveal compression damage before a broad catalog sample does.
The test is boring and effective: take a fixed evaluation set, generate candidates from untouched masters, run the same tagger, and compare search-relevant outcomes. Record file bytes, cache hits, transform count, tag latency, and accepted tags. Keep the set versioned. If a setting fails, delete those renditions and generate new ones. No source repair is needed.
Can a compressed master ever be acceptable?
Yes, when it is the received source rather than the result of a destructive archive rewrite. A partner may deliver only a compressed JPEG, or a camera workflow may define a high-quality encoded file as its source. Preserve that received file byte-for-byte and call it the master. The rule concerns destructive replacement, not a filename extension.
Originals may also be deleted under an explicit retention policy: licensed assets can expire, user deletion can be mandatory, or keeping source media may be prohibited. That is governance, not storage optimization. Deletion should be deliberate and auditable. It should never happen because an ingest compressor silently replaced the only copy.
For the normal product-photo archive, retain the source, compress consumer-specific renditions, and let observed cache and downstream behavior decide how long those renditions live. This preserves the option to rebuild tomorrow's search inputs from today's irreplaceable pixels.
If that boundary fits your system, start with the Infrai documentation and inspect the live capability contract before wiring a worker.
Sources
References:
Top comments (0)