Avoid Reanalyzing the Same Image File in a Contact Import
Build a local exact-byte image queue, reuse completed observations deliberately, and keep every source contact separate.

Build a local exact-byte image queue, reuse completed observations deliberately, and keep every source contact separate.
Before submitting a collection of contact pictures, group byte-identical prepared files in your own importer. Submit one approved file for each group, then attach the completed observation to every original contact row in that group. Keep contact identity separate from image reuse.
Deduplicate the file you will actually send
A contact export can contain the same company logo on many records. Sending that identical file repeatedly creates repeated work without adding a new image input. The useful comparison is between the final files that will be uploaded, after any deliberate rotation, resize, or conversion.
Our Image Profile Analysis accepts a single supported picture through the documented multipart API. It accepts JPEG, PNG, WebP, and GIF up to 2 MB. A local import containing many files still needs its own work queue; this grouping step is your application logic.
Prepare each file once, inspect its appearance, and save the exact derivative. Keep its source record key and original image reference in a local manifest. Hashing the original and then uploading a newly encoded copy would make the manifest describe different bytes from the request. Avoid that by treating the prepared file as immutable for the duration of the import.
Use an exact comparison, not a resemblance score
A byte digest is a useful index into groups of identical content. Python's hashlib.sha256 accepts bytes and returns a digest that your program can use as a lookup key. For a conservative grouping step, compare the bytes within a digest group as well. A resemblance algorithm answers a broader question: a cropped or re-encoded picture may look similar while containing different bytes.
The example below builds work without calling an API. Each input row contains a source record key and the path to an already prepared file. All values in jobs, including digest and source_record_keys, belong to the importer.
from hashlib import sha256
from pathlib import Path
def build_jobs(rows, config_version):
buckets = {}
jobs = []
for row in rows:
payload = Path(row["prepared_path"]).read_bytes()
digest = sha256(payload).hexdigest()
key = (config_version, digest)
candidates = buckets.setdefault(key, [])
job = next((j for j in candidates
if j["payload"] == payload), None)
if job is None:
job = {"digest": digest, "payload": payload,
"source_record_keys": [], "config": config_version}
candidates.append(job)
jobs.append(job)
job["source_record_keys"].append(row["source_record_key"])
return jobs
For large collections, put prepared files in controlled storage and retain references instead of keeping every payload in memory. The same rule still applies: a worker must submit the exact file represented by the grouping key. A file that changes between preparation and upload belongs in a new group.
Keep every contact when sharing one observation
Suppose contact rows C10 and C11 point to the same logo file, while C12 points to a different picture. The manifest contains three contact rows and the queue contains two image jobs. After the logo's completed analysis, both C10 and C11 can reference that observation under the team's policy. Neither contact disappears.
| Local source row | Prepared file group | Import action |
|---|---|---|
| C10 | Logo A | Link to the completed observation for Logo A |
| C11 | Logo A | Keep a separate contact link to that observation |
| C12 | Picture B | Wait for Picture B's own completed observation |
Store the observation with the submitted-file digest, configuration version, check time, and product used. Then create a separate source-row link for each member of source_record_keys. Reusing one image observation does not establish that two accounts belong to one person. A shared company logo is an obvious example of why the accounts must remain separate.
The content fingerprint returned by image analysis has its own meaning in the product response. Do not assume it uses your local SHA-256 algorithm or replace an account identifier with it. Your local digest organizes submitted bytes; a source record key identifies the application row receiving the observation.
Reuse completed work deliberately
After a completed analysis, fan out the observation to the source rows still linked to the exact prepared image. A nonhuman category or unknown appearance attribute can be part of a completed result. Preserve that output rather than submitting the same image again merely because it was not the category someone expected.
An unreadable image, service failure, or response with no usable fields needs its own failure path. Keep the job pending or unresolved according to a bounded policy, and keep its source-row links attached. Do not publish a failure as a completed “no avatar” result. Record an attempt separately from the completed observation so that a retry does not make it appear that two independent images were analyzed.
For reuse across imports, define an application-owned validity rule. At minimum, compare the exact submitted bytes, preparation version, selected product, and the analysis configuration your application uses. If any relevant input changes, create a new job or request a new observation. An old local result should not silently cover a new derivative because the file name stayed the same. Any reuse period is your team's policy, not an assumed service cache lifetime.
Check the grouping before connecting the worker
Test the local function with two identical files under different paths, a modified copy, and two contacts referencing one file. The first pair should share a job; the modified file should not. Both contact record keys must survive the shared job. Also check a missing path and a file that changes after manifest creation: those cases should stop that input for repair rather than attach a convenient earlier result.
Use a preview report showing original source rows, unique prepared-image jobs, repeated-file groups, and unreadable inputs. These counts describe your importer; they are not a measured product saving or a claim that every visually similar picture can reuse a result.
Once the report is correct, connect the unique jobs to the documented image-upload request in the API reference. Keep the worker and the fan-out step separate so a reviewer can trace which exact file produced each stored observation.
Learn More
Choose the product information that fits the next step in your workflow.