Skip to content

Image Requirements

How to get the best diagnosis results from your images.


Supported Formats

Format MIME Type Extension
JPEG image/jpeg .jpg, .jpeg
PNG image/png .png
WebP image/webp .webp
HEIC image/heic, image/heif .heic, .heif

Size Limits

Constraint Value
Maximum file size 10 MB
Minimum recommended 100 KB
Optimal range 500 KB – 5 MB

Files over 10 MB will be rejected

The API returns a 400 error. Compress or resize the image before sending.

Compression Example

from PIL import Image
import io

def compress_for_api(image_path, max_mb=10):
    """Compress image to fit under API limit."""
    img = Image.open(image_path)

    if img.mode in ("RGBA", "P"):
        img = img.convert("RGB")

    quality = 95
    while quality > 10:
        buffer = io.BytesIO()
        img.save(buffer, format="JPEG", quality=quality)
        if buffer.tell() / (1024 * 1024) <= max_mb:
            buffer.seek(0)
            return buffer
        quality -= 10

    return buffer

Image Quality Tips

Good Images

For accurate diagnosis, your image should be:

Criteria Recommendation
Lighting Natural daylight, avoid harsh shadows
Focus Sharp focus on the affected area
Distance Close enough to see symptoms clearly (20-50 cm)
Coverage Include both healthy and affected parts
Background Avoid cluttered backgrounds

Best practice

Capture 2-3 photos: one close-up of the affected area, one of the whole plant, and one showing the field context. Send the close-up for best results.

What to Avoid

Issue Impact Solution
Blurry image Low confidence scores Hold steady, tap to focus
Too dark May not detect symptoms Use natural light
Too far Symptoms not visible Get closer (20-50 cm)
Multiple plants Confusing results Focus on one plant
Finger in frame Partial occlusion Check framing before capture

Image Quality Feedback

The API provides image quality feedback when issues are detected:

{
  "is_plant": true,
  "image_quality_issue": "Image is too blurry for accurate diagnosis. Please provide a clearer photo.",
  "crop_health": "unknown",
  "diagnoses": []
}

Possible quality issues:

  • "Image is too blurry" — Camera out of focus
  • "Image is too dark" — Insufficient lighting
  • "Unable to identify plant parts" — Image too far or unclear
  • null — No quality issues detected

Non-Plant Images

If the image does not contain a plant:

{
  "is_plant": false,
  "crop_health": "unknown",
  "diagnoses": [],
  "additional_notes": "The image does not appear to contain a plant."
}

Always check the is_plant field before processing the diagnosis.


Mobile Capture Guidelines

For mobile applications integrating Tajiri Vision:

Camera Settings

Resolution:  1280x960 or higher
Format:      JPEG (smaller file size)
Quality:     80-90% compression
Flash:       Off (use natural light)

Android Example

val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
// Set max resolution
intent.putExtra("android.intent.extra.sizeLimit", 10 * 1024 * 1024)
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE)

iOS Example

let picker = UIImagePickerController()
picker.sourceType = .camera
picker.cameraDevice = .rear
// Compress before upload
let imageData = image.jpegData(compressionQuality: 0.85)

Bandwidth Optimization

For low-bandwidth environments (2G/3G networks common in rural areas):

Strategy Savings How
JPEG over PNG 60-80% smaller Use JPEG for photos
Resize to 1280px ~50% smaller Scale down before upload
Compress quality 80% ~40% smaller Balance quality vs size
WebP format ~25% smaller than JPEG If client supports it

Python: Optimize Before Upload

from PIL import Image
import io

def optimize_image(image_path, max_dimension=1280):
    """Optimize image for low-bandwidth upload."""
    img = Image.open(image_path)

    # Resize if too large
    if max(img.size) > max_dimension:
        img.thumbnail((max_dimension, max_dimension))

    # Convert to RGB JPEG
    if img.mode != "RGB":
        img = img.convert("RGB")

    buffer = io.BytesIO()
    img.save(buffer, format="JPEG", quality=80, optimize=True)
    buffer.seek(0)
    return buffer

# Usage
optimized = optimize_image("large_photo.jpg")
response = requests.post(
    "https://api.tajirifarm.com/diagnosis/",
    files={"image": ("photo.jpg", optimized, "image/jpeg")}
)