Image Preprocessing¶
Class: ImagePreprocessingBlockV1
Source: inference.core.workflows.core_steps.classical_cv.image_preprocessing.v1.ImagePreprocessingBlockV1
Apply geometric transformations to images including resizing to specified dimensions (with aspect ratio preservation), rotating by specified degrees (clockwise or counterclockwise), or flipping vertically, horizontally, or both, providing flexible image preprocessing for model input preparation, image orientation correction, and geometric image manipulation workflows.
How This Block Works¶
This block applies one geometric transformation operation (resize, rotate, or flip) to an input image based on the selected task_type. The block:
- Receives an input image and selects one transformation task (resize, rotate, or flip)
- Validates task-specific parameters (width/height for resize, rotation_degrees for rotate, flip_type for flip)
- Applies the selected transformation:
For resize task: - Validates width and height are positive integers (greater than 0) - Supports aspect ratio preservation: if only width or only height is provided, calculates the missing dimension to maintain the original aspect ratio - If both width and height are provided, resizes to exact dimensions (may distort aspect ratio) - Uses OpenCV's INTER_AREA interpolation for high-quality downsampling - Returns resized image with specified dimensions
For rotate task: - Validates rotation_degrees is between -360 and 360 degrees - Positive values rotate clockwise, negative values rotate counterclockwise - Calculates rotation matrix around image center - Automatically adjusts canvas size to contain the rotated image (no cropping) - Uses OpenCV's warpAffine for smooth rotation with bilinear interpolation - Returns rotated image with canvas sized to fit the full rotated image
For flip task: - Validates flip_type is "vertical", "horizontal", or "both" - Vertical flip: flips image upside down (mirrors along horizontal axis) - Horizontal flip: flips image left-right (mirrors along vertical axis) - Both: applies both vertical and horizontal flips simultaneously (180-degree rotation equivalent) - Uses OpenCV's flip function for efficient mirroring - Returns flipped image with same dimensions as input
- Preserves image metadata from the original image (parent metadata, image properties)
- Returns the transformed image maintaining original image metadata structure
The block performs one transformation at a time - select resize, rotate, or flip via task_type. Each transformation is applied independently and produces a clean output. Resize supports flexible aspect ratio handling, rotation automatically adjusts canvas size to prevent cropping, and flip operations provide efficient mirroring along different axes. The transformations use OpenCV for efficient, high-quality geometric image manipulation.
Common Use Cases¶
- Model Input Preparation: Resize images to match model input requirements (e.g., resize images to specific dimensions for object detection models, adjust image sizes for classification model inputs, normalize image dimensions for consistent model processing), enabling proper model input formatting
- Image Orientation Correction: Rotate images to correct orientation issues (e.g., rotate images captured in wrong orientation, correct camera rotation, adjust image orientation for proper display), enabling image orientation workflows
- Data Augmentation: Apply geometric transformations for data augmentation (e.g., flip images horizontally for augmentation, rotate images for training data variety, apply transformations to increase dataset diversity), enabling data augmentation workflows
- Image Display Preparation: Transform images for display or presentation purposes (e.g., flip images for mirror effects, resize images for display dimensions, rotate images for correct viewing orientation), enabling image presentation workflows
- Workflow Image Standardization: Standardize image dimensions or orientation across workflow inputs (e.g., resize all images to consistent dimensions, normalize image orientations, prepare images for uniform processing), enabling image standardization workflows
- Image Formatting for Downstream Blocks: Prepare images for blocks that require specific dimensions or orientations (e.g., resize before detection models, rotate for proper processing, flip for compatibility with other blocks), enabling image preparation workflows
Connecting to Other Blocks¶
This block receives an image and produces a transformed image:
- After image input blocks to preprocess images before further processing (e.g., resize input images, correct image orientation, prepare images for workflow processing), enabling image preprocessing workflows
- Before detection or classification models to format images for model requirements (e.g., resize to model input dimensions, adjust orientation for proper detection, prepare images for model processing), enabling model-compatible image preparation
- Before crop blocks to prepare images before cropping (e.g., resize before cropping, rotate before region extraction, adjust orientation before cropping), enabling pre-crop image preparation
- Before visualization blocks to prepare images for display (e.g., resize for display, rotate for proper viewing, flip for presentation), enabling image display preparation workflows
- In image processing pipelines where geometric transformations are needed (e.g., resize in multi-stage pipelines, rotate in processing workflows, flip in transformation chains), enabling geometric transformation pipelines
- After other transformation blocks to apply additional geometric operations (e.g., resize after cropping, rotate after other transformations, flip after processing), enabling multi-stage geometric transformation workflows
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/image_preprocessing@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
task_type |
str |
Type of geometric transformation to apply to the image: 'resize' to change image dimensions (requires width/height), 'rotate' to rotate the image by specified degrees (requires rotation_degrees), or 'flip' to mirror the image along axes (requires flip_type). Only one transformation is applied per block execution. Select the appropriate task type based on your preprocessing needs.. | ❌ |
width |
int |
Target width in pixels for resizing. Required when task_type is 'resize'. Must be a positive integer (greater than 0). If only width is provided (height is None), the height is automatically calculated to preserve aspect ratio. If both width and height are provided, the image is resized to exact dimensions (may distort aspect ratio). Default is 640 pixels. Use this to resize images to specific dimensions for model inputs or display requirements.. | ✅ |
height |
int |
Target height in pixels for resizing. Required when task_type is 'resize'. Must be a positive integer (greater than 0). If only height is provided (width is None), the width is automatically calculated to preserve aspect ratio. If both width and height are provided, the image is resized to exact dimensions (may distort aspect ratio). Default is 640 pixels. Use this to resize images to specific dimensions for model inputs or display requirements.. | ✅ |
rotation_degrees |
int |
Rotation angle in degrees. Required when task_type is 'rotate'. Must be between -360 and 360 degrees. Positive values rotate the image clockwise, negative values rotate counterclockwise. The rotation is performed around the image center, and the canvas size is automatically adjusted to contain the full rotated image (no cropping occurs). For example, 90 rotates 90 degrees clockwise, -90 rotates 90 degrees counterclockwise, 180 rotates 180 degrees. Default is 90 degrees.. | ✅ |
flip_type |
str |
Type of flip operation to apply. Required when task_type is 'flip'. Options: 'vertical' flips the image upside down (mirrors along horizontal axis, top becomes bottom), 'horizontal' flips left-right (mirrors along vertical axis, left becomes right), 'both' applies both vertical and horizontal flips simultaneously (equivalent to 180-degree rotation). The image dimensions remain unchanged after flipping. Default is 'vertical'. Use this for mirroring images or data augmentation.. | ✅ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Image Preprocessing in version v1.
- inputs:
Absolute Static Crop,Qwen-VL,Triangle Visualization,EasyOCR,Model Comparison Visualization,Detection Event Log,Stitch OCR Detections,Llama 3.2 Vision,Heatmap Visualization,Stitch Images,Keypoint Visualization,Anthropic Claude,Webhook Sink,Google Gemini,GLM-OCR,QR Code Generator,MoonshotAI Kimi,VLM As Detector,Multi-Label Classification Model,Twilio SMS/MMS Notification,Line Counter,Distance Measurement,Ellipse Visualization,Pixelate Visualization,Corner Visualization,Template Matching,Llama 3.2 Vision,Qwen 3.5 API,LMM,Roboflow Visual Search,OpenAI-Compatible LLM,Morphological Transformation,Color Visualization,Roboflow Dataset Upload,Morphological Transformation,Camera Calibration,Google Vision OCR,Clip Comparison,Bounding Box Visualization,OpenAI,Halo Visualization,Contrast Equalization,CSV Formatter,Model Monitoring Inference Aggregator,MQTT Writer,Image Threshold,Blur Visualization,Line Counter Visualization,Google Gemini,Microsoft SQL Server Sink,Single-Label Classification Model,Background Subtraction,VLM As Classifier,Instance Segmentation Model,Twilio SMS Notification,Polygon Zone Visualization,OPC UA Writer Sink,Google Gemma API,Reference Path Visualization,Image Stack,Stability AI Inpainting,Crop Visualization,Anthropic Claude,Image Convert Grayscale,Camera Focus,Image Slicer,Florence-2 Model,Polygon Visualization,MoonshotAI Kimi,Dynamic Crop,Qwen 3.6 API,Event Writer,Perspective Correction,Line Counter,Polygon Visualization,OCR Model,Roboflow Visual Search Classifier,Circle Visualization,Slack Notification,CogVLM,Contrast Enhancement,Grid Visualization,LMM For Classification,Florence-2 Model,OpenAI,Local File Sink,Roboflow Custom Metadata,Qwen3.5-VL,Image Blur,Label Visualization,Object Detection Model,Anthropic Claude,Pixel Color Count,Roboflow Vision Events,Image Preprocessing,Trace Visualization,Email Notification,SIFT Comparison,Stability AI Outpainting,Dot Visualization,Current Time,Keypoint Detection Model,Roboflow Asset Library Attributes,Halo Visualization,Classification Label Visualization,Image Contours,Camera Focus,OpenRouter,S3 Sink,Stability AI Image Generation,Google Gemma,Relative Static Crop,Roboflow Dataset Upload,OpenAI,Image Slicer,Stitch OCR Detections,Google Gemini,Email Notification,Text Display,Depth Estimation,Icon Visualization,OpenAI,PLC Writer,SIFT Comparison,SIFT,Background Color Visualization,Mask Visualization - outputs:
Absolute Static Crop,VLM As Classifier,Qwen-VL,Gaze Detection,Triangle Visualization,EasyOCR,Model Comparison Visualization,OC-SORT Tracker,YOLO-World Model,Track Class Lock,Llama 3.2 Vision,Anthropic Claude,Heatmap Visualization,Stitch Images,Keypoint Visualization,Detections Stabilizer,Google Gemini,Dominant Color,MoonshotAI Kimi,GLM-OCR,Instance Segmentation Model,VLM As Detector,SAM2 Video Tracker,Multi-Label Classification Model,Twilio SMS/MMS Notification,Ellipse Visualization,Single-Label Classification Model,SmolVLM2,Keypoint Detection Model,Pixelate Visualization,Corner Visualization,Buffer,Template Matching,Llama 3.2 Vision,Qwen2.5-VL,Qwen 3.5 API,LMM,Semantic Segmentation Model,Roboflow Visual Search,Morphological Transformation,Color Visualization,Roboflow Dataset Upload,Morphological Transformation,Camera Calibration,Motion Detection,Google Vision OCR,Clip Comparison,Bounding Box Visualization,OpenAI,Halo Visualization,SAM3 Video Tracker,Object Detection Model,Contrast Equalization,Instance Segmentation Model,Multi-Label Classification Model,Image Threshold,Blur Visualization,Line Counter Visualization,Google Gemini,Single-Label Classification Model,Background Subtraction,Object Detection Model,Instance Segmentation Model,SAM 3,QR Code Detection,Polygon Zone Visualization,Google Gemma API,Keypoint Detection Model,Image Stack,Reference Path Visualization,SAM 3 Interactive,Qwen3-VL,Stability AI Inpainting,Multi-Label Classification Model,Perception Encoder Embedding Model,Crop Visualization,Anthropic Claude,Image Convert Grayscale,Camera Focus,Image Slicer,Florence-2 Model,Polygon Visualization,MoonshotAI Kimi,Dynamic Crop,Qwen 3.6 API,Event Writer,Perspective Correction,Segment Anything 2 Model,Polygon Visualization,Clip Comparison,OCR Model,Roboflow Visual Search Classifier,Circle Visualization,CogVLM,Contrast Enhancement,Mask Edge Snap,Barcode Detection,Time in Zone,LMM For Classification,Qwen3.5-VL,Florence-2 Model,OpenAI,SORT Tracker,ByteTrack Tracker,Label Visualization,Image Blur,Seg Preview,Object Detection Model,Anthropic Claude,Pixel Color Count,Roboflow Vision Events,Image Preprocessing,Trace Visualization,Email Notification,SIFT Comparison,Stability AI Outpainting,Keypoint Detection Model,Dot Visualization,Halo Visualization,SAM 3,Classification Label Visualization,Mask Visualization,Image Contours,Camera Focus,Single-Label Classification Model,OpenRouter,Moondream2,Stability AI Image Generation,VLM As Detector,Google Gemma,CLIP Embedding Model,Relative Static Crop,Roboflow Dataset Upload,OpenAI,Image Slicer,Google Gemini,BoT-SORT Tracker,Byte Tracker,SAM 3,Detections Stitch,Semantic Segmentation Model,Text Display,Qwen3.5,Depth Estimation,Icon Visualization,OpenAI,GeoTag Detection,SIFT,Instance Segmentation Model,Background Color Visualization,VLM As Classifier
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Image Preprocessing in version v1 has.
Bindings
-
input
image(image): Input image to transform. The image will have one geometric transformation applied (resize, rotate, or flip) based on the selected task_type. Supports images from inputs, previous workflow steps, or crop outputs. The output image maintains the original image's metadata structure..width(integer): Target width in pixels for resizing. Required when task_type is 'resize'. Must be a positive integer (greater than 0). If only width is provided (height is None), the height is automatically calculated to preserve aspect ratio. If both width and height are provided, the image is resized to exact dimensions (may distort aspect ratio). Default is 640 pixels. Use this to resize images to specific dimensions for model inputs or display requirements..height(integer): Target height in pixels for resizing. Required when task_type is 'resize'. Must be a positive integer (greater than 0). If only height is provided (width is None), the width is automatically calculated to preserve aspect ratio. If both width and height are provided, the image is resized to exact dimensions (may distort aspect ratio). Default is 640 pixels. Use this to resize images to specific dimensions for model inputs or display requirements..rotation_degrees(integer): Rotation angle in degrees. Required when task_type is 'rotate'. Must be between -360 and 360 degrees. Positive values rotate the image clockwise, negative values rotate counterclockwise. The rotation is performed around the image center, and the canvas size is automatically adjusted to contain the full rotated image (no cropping occurs). For example, 90 rotates 90 degrees clockwise, -90 rotates 90 degrees counterclockwise, 180 rotates 180 degrees. Default is 90 degrees..flip_type(string): Type of flip operation to apply. Required when task_type is 'flip'. Options: 'vertical' flips the image upside down (mirrors along horizontal axis, top becomes bottom), 'horizontal' flips left-right (mirrors along vertical axis, left becomes right), 'both' applies both vertical and horizontal flips simultaneously (equivalent to 180-degree rotation). The image dimensions remain unchanged after flipping. Default is 'vertical'. Use this for mirroring images or data augmentation..
-
output
image(image): Image in workflows.
Example JSON definition of step Image Preprocessing in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/image_preprocessing@v1",
"image": "$inputs.image",
"task_type": "<block_does_not_provide_example>",
"width": 640,
"height": 640,
"rotation_degrees": 90,
"flip_type": "vertical"
}