210 lines
6.7 KiB
Java
210 lines
6.7 KiB
Java
|
|
// This file is auto-generated by alef — DO NOT EDIT.
|
||
|
|
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||
|
|
// To regenerate: alef generate
|
||
|
|
// To verify freshness: alef verify --exit-code
|
||
|
|
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
||
|
|
package dev.kreuzberg;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||
|
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||
|
|
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
|
||
|
|
import org.jspecify.annotations.Nullable;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Image preprocessing metadata.
|
||
|
|
*
|
||
|
|
* Tracks the transformations applied to an image during OCR preprocessing,
|
||
|
|
* including DPI normalization, resizing, and resampling.
|
||
|
|
*/
|
||
|
|
@JsonInclude(JsonInclude.Include.NON_ABSENT)
|
||
|
|
@JsonDeserialize(builder = ImagePreprocessingMetadata.Builder.class)
|
||
|
|
public record ImagePreprocessingMetadata(
|
||
|
|
/**
|
||
|
|
* Original image dimensions (width, height) in pixels
|
||
|
|
*/
|
||
|
|
@JsonProperty("original_dimensions") List<Long> originalDimensions,
|
||
|
|
/**
|
||
|
|
* Original image DPI (horizontal, vertical)
|
||
|
|
*/
|
||
|
|
@JsonProperty("original_dpi") List<Double> originalDpi,
|
||
|
|
/**
|
||
|
|
* Target DPI from configuration
|
||
|
|
*/
|
||
|
|
@JsonProperty("target_dpi") int targetDpi,
|
||
|
|
/**
|
||
|
|
* Scaling factor applied to the image
|
||
|
|
*/
|
||
|
|
@JsonProperty("scale_factor") double scaleFactor,
|
||
|
|
/**
|
||
|
|
* Whether DPI was auto-adjusted based on content
|
||
|
|
*/
|
||
|
|
@JsonProperty("auto_adjusted") boolean autoAdjusted,
|
||
|
|
/**
|
||
|
|
* Final DPI after processing
|
||
|
|
*/
|
||
|
|
@JsonProperty("final_dpi") int finalDpi,
|
||
|
|
/**
|
||
|
|
* New dimensions after resizing (if resized)
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("new_dimensions") List<Long> newDimensions,
|
||
|
|
/**
|
||
|
|
* Resampling algorithm used ("LANCZOS3", "CATMULLROM", etc.)
|
||
|
|
*/
|
||
|
|
@JsonProperty("resample_method") String resampleMethod,
|
||
|
|
/**
|
||
|
|
* Whether dimensions were clamped to max_image_dimension
|
||
|
|
*/
|
||
|
|
@JsonProperty("dimension_clamped") boolean dimensionClamped,
|
||
|
|
/**
|
||
|
|
* Calculated optimal DPI (if auto_adjust_dpi enabled)
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("calculated_dpi") Integer calculatedDpi,
|
||
|
|
/**
|
||
|
|
* Whether resize was skipped (dimensions already optimal)
|
||
|
|
*/
|
||
|
|
@JsonProperty("skipped_resize") boolean skippedResize,
|
||
|
|
/**
|
||
|
|
* Error message if resize failed
|
||
|
|
*/
|
||
|
|
@Nullable @JsonProperty("resize_error") String resizeError
|
||
|
|
) {
|
||
|
|
public static Builder builder() {
|
||
|
|
return new Builder();
|
||
|
|
}
|
||
|
|
|
||
|
|
// CPD-OFF
|
||
|
|
@JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
|
||
|
|
public static final class Builder {
|
||
|
|
|
||
|
|
@JsonProperty("original_dimensions")
|
||
|
|
private List<Long> originalDimensions = List.of();
|
||
|
|
@JsonProperty("original_dpi")
|
||
|
|
private List<Double> originalDpi = List.of();
|
||
|
|
@JsonProperty("target_dpi")
|
||
|
|
private int targetDpi = 0;
|
||
|
|
@JsonProperty("scale_factor")
|
||
|
|
private double scaleFactor = 0.0;
|
||
|
|
@JsonProperty("auto_adjusted")
|
||
|
|
private boolean autoAdjusted = false;
|
||
|
|
@JsonProperty("final_dpi")
|
||
|
|
private int finalDpi = 0;
|
||
|
|
@JsonProperty("new_dimensions")
|
||
|
|
private List<Long> newDimensions = null;
|
||
|
|
@JsonProperty("resample_method")
|
||
|
|
private String resampleMethod = "";
|
||
|
|
@JsonProperty("dimension_clamped")
|
||
|
|
private boolean dimensionClamped = false;
|
||
|
|
@JsonProperty("calculated_dpi")
|
||
|
|
private Integer calculatedDpi = null;
|
||
|
|
@JsonProperty("skipped_resize")
|
||
|
|
private boolean skippedResize = false;
|
||
|
|
@JsonProperty("resize_error")
|
||
|
|
private String resizeError = null;
|
||
|
|
|
||
|
|
/** Sets the originalDimensions field. */
|
||
|
|
@JsonProperty("original_dimensions")
|
||
|
|
public Builder withOriginalDimensions(final List<Long> value) {
|
||
|
|
this.originalDimensions = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the originalDpi field. */
|
||
|
|
@JsonProperty("original_dpi")
|
||
|
|
public Builder withOriginalDpi(final List<Double> value) {
|
||
|
|
this.originalDpi = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the targetDpi field. */
|
||
|
|
@JsonProperty("target_dpi")
|
||
|
|
public Builder withTargetDpi(final int value) {
|
||
|
|
this.targetDpi = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the scaleFactor field. */
|
||
|
|
@JsonProperty("scale_factor")
|
||
|
|
public Builder withScaleFactor(final double value) {
|
||
|
|
this.scaleFactor = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the autoAdjusted field. */
|
||
|
|
@JsonProperty("auto_adjusted")
|
||
|
|
public Builder withAutoAdjusted(final boolean value) {
|
||
|
|
this.autoAdjusted = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the finalDpi field. */
|
||
|
|
@JsonProperty("final_dpi")
|
||
|
|
public Builder withFinalDpi(final int value) {
|
||
|
|
this.finalDpi = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the newDimensions field. */
|
||
|
|
@JsonProperty("new_dimensions")
|
||
|
|
public Builder withNewDimensions(final @Nullable List<Long> value) {
|
||
|
|
this.newDimensions = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the resampleMethod field. */
|
||
|
|
@JsonProperty("resample_method")
|
||
|
|
public Builder withResampleMethod(final String value) {
|
||
|
|
this.resampleMethod = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the dimensionClamped field. */
|
||
|
|
@JsonProperty("dimension_clamped")
|
||
|
|
public Builder withDimensionClamped(final boolean value) {
|
||
|
|
this.dimensionClamped = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the calculatedDpi field. */
|
||
|
|
@JsonProperty("calculated_dpi")
|
||
|
|
public Builder withCalculatedDpi(final @Nullable int value) {
|
||
|
|
this.calculatedDpi = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the skippedResize field. */
|
||
|
|
@JsonProperty("skipped_resize")
|
||
|
|
public Builder withSkippedResize(final boolean value) {
|
||
|
|
this.skippedResize = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Sets the resizeError field. */
|
||
|
|
@JsonProperty("resize_error")
|
||
|
|
public Builder withResizeError(final @Nullable String value) {
|
||
|
|
this.resizeError = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** Builds the ImagePreprocessingMetadata instance. */
|
||
|
|
public ImagePreprocessingMetadata build() {
|
||
|
|
return new ImagePreprocessingMetadata(
|
||
|
|
originalDimensions,
|
||
|
|
originalDpi,
|
||
|
|
targetDpi,
|
||
|
|
scaleFactor,
|
||
|
|
autoAdjusted,
|
||
|
|
finalDpi,
|
||
|
|
newDimensions,
|
||
|
|
resampleMethod,
|
||
|
|
dimensionClamped,
|
||
|
|
calculatedDpi,
|
||
|
|
skippedResize,
|
||
|
|
resizeError
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// CPD-ON
|
||
|
|
}
|