syntax = "proto3";

package com.wix.media.site_media.v1;

import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "com/wix/media/site_media/upstream/wix/common/media.proto";
import "wix/api/annotations.proto";

message ColorRGB {
  // Red channel.
  google.protobuf.Int32Value r = 1 [(.wix.api.min) = 0, (.wix.api.max) = 255];
  // Green channel.
  google.protobuf.Int32Value g = 2 [(.wix.api.min) = 0, (.wix.api.max) = 255];
  // Blue channel.
  google.protobuf.Int32Value b = 3 [(.wix.api.min) = 0, (.wix.api.max) = 255];
}

message Color {
  // HEX color.
  google.protobuf.StringValue hex = 1 [(.wix.api.format) = COLOR_HEX];
  // RGB color.
  ColorRGB rgb = 2;
}

message Colors {
  // Main color of the image.
  Color prominent = 1;
  // Color palette of the image. 
  repeated Color palette = 2 [(.wix.api.maxSize) = 100];
}

// Using this object you can crop images while centering on faces
//------------------------
//|                      |
//|    x,y               |
//|    *--------         |
//|    |  .  . |         |
//|    |   |   | height  |
//|    |  \ /  |         |
//|    |       |         |
//|    ---------         |
//|     width            |
//|                      |
//|______________________|
message FaceRecognition {
  // The accuracy percentage of the face recognition. The likelihood that a face is detected. 
  double confidence = 1;
  // Top left x pixel coordinate of the face.
  int32 x = 2;
  // Top left y pixel coordinate of the face.
  int32 y = 3;
  // Face pixel height.
  int32 height = 4;
  // Face pixel width.
  int32 width = 5;

}

message ImageMedia {
  // Image data.
  //flynt-disable field-type-breaking-change
  com.wix.media.site_media.upstream.wix.common.Image image = 1;

  // Image colors.
  Colors colors = 2;

  /* Information about faces in the image. Use to crop images without cutting out faces.
  */ 
  repeated FaceRecognition faces = 3 [(.wix.api.maxSize) = 100];

  // Information about the image preview.
  // You can use this to display a preview for private images.
  //flynt-disable field-type-breaking-change
  com.wix.media.site_media.upstream.wix.common.Image preview_image = 4;

  // Optional, An AI generated description of the image
  google.protobuf.StringValue caption = 5 [(.wix.api.readOnly) = true, (.wix.api.maxLength) = 300];

  // Optional, return true or false if the image has text, or empty for unknown
  google.protobuf.BoolValue contains_text = 6 [(.wix.api.readOnly) = true, (.wix.api.field_exposure) = INTERNAL];
  // Optional, return true or false if the image has text, or empty for unknown
  google.protobuf.BoolValue animated = 7 [(.wix.api.readOnly) = true, (.wix.api.field_exposure) = INTERNAL];
}
