Home / Function/ imageMetadata() — astro Function Reference

imageMetadata() — astro Function Reference

Architecture documentation for the imageMetadata() function in metadata.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  fe03d578_04f0_7fd4_f32d_af3a508dbab2["imageMetadata()"]
  f7e2fa0f_185a_721c_2dec_cc06429c3ee5["metadata.ts"]
  fe03d578_04f0_7fd4_f32d_af3a508dbab2 -->|defined in| f7e2fa0f_185a_721c_2dec_cc06429c3ee5
  style fe03d578_04f0_7fd4_f32d_af3a508dbab2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/assets/utils/metadata.ts lines 13–42

export async function imageMetadata(
	data: Uint8Array,
	src?: string,
): Promise<Omit<ImageMetadata, 'src' | 'fsPath'>> {
	let result;
	try {
		result = probe(data);
	} catch {
		throw new AstroError({
			...AstroErrorData.NoImageMetadata,
			message: AstroErrorData.NoImageMetadata.message(src),
		});
	}
	if (!result.height || !result.width || !result.type) {
		throw new AstroError({
			...AstroErrorData.NoImageMetadata,
			message: AstroErrorData.NoImageMetadata.message(src),
		});
	}

	const { width, height, type, orientation } = result;
	const isPortrait = (orientation || 0) >= 5;

	return {
		width: isPortrait ? height : width,
		height: isPortrait ? width : height,
		format: type as ImageInputFormat,
		orientation,
	};
}

Domain

Subdomains

Frequently Asked Questions

What does imageMetadata() do?
imageMetadata() is a function in the astro codebase, defined in packages/astro/src/assets/utils/metadata.ts.
Where is imageMetadata() defined?
imageMetadata() is defined in packages/astro/src/assets/utils/metadata.ts at line 13.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free