Sign up and contact support to get 100 free checks.Sign up free
AvatarLookup workflow illustration for Resize an Image Before an Image Analysis API Upload
A visual overview of the workflow discussed in this AvatarLookup article.

Resize an image before an image analysis API upload only when the original exceeds the supported file size or needs a deliberate format conversion. AvatarLookup’s image profile analysis accepts JPEG, PNG, WebP, or GIF files up to 2 MB. Preserve the original, create a separate derivative, and inspect what the transformation actually shows. Fitting preserves the whole subject; cropping can remove de

Resize an image before an image analysis API upload only when the original exceeds the supported file size or needs a deliberate format conversion. AvatarLookup’s image profile analysis accepts JPEG, PNG, WebP, or GIF files up to 2 MB. Preserve the original, create a separate derivative, and inspect what the transformation actually shows. Fitting preserves the whole subject; cropping can remove details; stretching changes proportions. If a transparent image is converted to JPEG, choose the background color explicitly. Check the derivative’s final format, dimensions, byte size, and visible subject before sending its file as multipart input.

Submit the original when it already meets the contract

The first optimization is often to avoid transforming the picture at all. Inspect the source file’s actual format and byte count. If it is a supported JPEG, PNG, WebP, or GIF within AvatarLookup’s 2 MB image-profile limit and shows the intended subject, submit that file unchanged. Keep the original in the team’s own storage so later reviews can tell what was analyzed. The documented REST route accepts a multipart file at POST /api/v1/image/profile; a website public-URL input does not establish an API URL payload.

If the file does not qualify, record why a derivative is needed: unsupported format, excessive bytes, large pixel dimensions, transparency requiring a different output format, or an unintended crop in the source. Size reduction is an input-preparation step, not evidence that the resulting category will be more accurate. Do not claim a universal best portrait dimension. A photo that already fits should not be repeatedly compressed just to make a smaller number.

Decide what must remain visible before choosing a transform. For a profile picture, the full intended subject and relevant border area may matter; a developer should not let an automatic center crop silently change the picture under review.

Choose fit deliberately instead of stretching or cropping

The Sharp resize documentation distinguishes fit modes. An “inside” fit reduces dimensions to stay within bounds while keeping aspect ratio and all visible content. A “cover” fit fills a target box and may crop edges. Stretching to a fixed width and height without preserving aspect ratio distorts the subject. For a general preparation pipeline, start with aspect-preserving fit and without-enlargement behavior, then inspect the result.

Cropping is appropriate only when the chosen review task actually calls for that crop and an operator can verify the retained subject. A centered square crop may remove a hat, hair, logo edge, or contextual object. Even if the transformed file is technically valid, it may no longer be the picture the caller meant to analyze. Store the transform method alongside the derivative, rather than treating all resized images as interchangeable.

Compression and resizing affect different properties. Shrinking pixel dimensions often reduces bytes, while output quality settings or format choices can change bytes without changing dimensions. The result varies by image content. Measure the encoded file after transformation instead of estimating its size from the original or from a quality number.

Handle transparent pixels before choosing JPEG

PNG and WebP can contain transparent pixels. JPEG cannot preserve alpha. If the derivative must be JPEG, the processor has to composite transparent areas onto a visible background. Sharp’s flatten operation supports an explicit background setting; its default is black, which may be unsuitable for a dark subject. Choose a background that lets the intended picture remain legible and preview the flattened result.

Do not automatically flatten every input. An accepted PNG or WebP below the size limit can preserve its original transparency. If a transparent logo or portrait has dark edges, a poorly chosen background can make them disappear; a different background or retained transparency may be the better derivative. Keep the original and the specific transform parameters so the team can reproduce or revise the choice.

GIF requires special attention because it can be animated. The supported format name alone does not answer which frame a particular processor or review workflow will expose. If motion changes what is depicted, decide on a deliberate frame or keep the original for manual review, and avoid claiming an undocumented AvatarLookup animation policy. The practical requirement is that the submitted bytes represent the intended picture.

Verify the final derivative as a file, not a plan

After encoding, inspect the derivative’s detected format, pixel dimensions, and actual byte count. Compare its preview side by side with the original. Check that the subject remains visible, aspect ratio is natural, transparency or background is intentional, and no edge was lost through a crop. Then verify that the final file is a supported format and within the 2 MB limit. A processor setting is only a proposed transformation until the resulting file passes these checks.

If it still exceeds the limit, adjust one parameter at a time, produce a new derivative, and inspect again. Do not overwrite the only original. If the format, bytes, or image content cannot be made suitable without altering the intended subject, stop and request a better source image. Sending a technically compliant but misleading derivative defeats the review task.

For a repeatable pipeline, save source-file reference, derivative reference, transform settings, final bytes and reviewer note in the caller’s own log. Submit the verified derivative through the AvatarLookup image profile endpoint as one multipart file. Treat any reported appearance or category as an algorithmic estimate about that submitted picture, not a statement about a person’s identity.

FAQ

When should an accepted original image be left unchanged?

If its detected format is supported, its final bytes fit the documented limit, and its visible subject matches the review task, submit the original. A smaller derivative has no automatic accuracy advantage. Preserve the original so the team can compare any later transformed file with the source.

Why can a square crop change the review?

A cover crop fills a target box by removing edge content. It may exclude part of the intended picture even though the output dimensions look correct. Use an aspect-preserving inside fit by default and inspect any deliberate crop before submission.

What happens to transparency when converting to JPEG?

JPEG has no alpha channel, so transparent pixels must be composited onto a background. Choose that background explicitly, preview the result, and keep the source. A supported PNG or WebP may be preferable when preserving transparency matters.

Learn More

Choose the product information that fits the next step in your workflow.

Sources