Skip to main content

Intelligent Crop

Intelligent Crop allows the user to crop an image around the specified object. For example, cropping the image around a bird, car, person.

This transformation supports png, jpeg, jpg, webp, heif, and heic type of files.


Params

Required width (w)

The required width of the output image (this value should not be greater than the actual image width).

Pot and Cup (width=3240px)original
Cropped Width (width=2956px)ic.crop(w:2956)

Required height (h)

The required height of the output image (this value should not be greater than the actual image height).

Pot and Cup (height=2592px)original
Cropped Height (height=2111px)ic.crop(h:2111)

Padding percentage (p)

It adds extra space around the cropped image.

For example, suppose the padding of 40% is applied to face cropping. If the earlier crop dimension was 100x100, then the new dimension will be 140x140, covering more regions in the crop.

Padding can’t increase dimensions beyond the original image size.

Pot and Cuporiginal
Cropped cupic.crop(g:object,obj:cup)
Cropped cup with paddingic.crop(g:object,obj:cup,p:40)

Maintain original aspect (ma)

If even after cropping the image, you need to maintain the same aspect ratio, this checkbox will save you from calculating the exact dimensions and do it for you. If you want a specific dimension, just pass either the width or the height parameter, or don’t pass to get the original aspect only.

If both height and width parameters are passed, or if the aspect ratio parameter is passed, then the maintain original aspect parameter will be ignored.

Pot and Cuporiginal
Cropped cupic.crop(g:object,obj:cup)
Cropped cup with maintained aspect ratioic.crop(g:object,obj:cup,ma:true)

Aspect ratio (ar)

Allows the user to specify the aspect ratio of the output image.

You can enter a custom aspect ratio in flexible formats (For example, [w_h] or [divided value of w/h] 16_9 or 2 or 0.25).

If both the height and width parameters are passed, then the aspect ratio parameter will be ignored. For example, if the height is 100 and the width is 100, then the aspect ratio becomes 1:1, which will override everything passed by the user.

Pot and Cuporiginal
Cropped cupic.crop(g:object,obj:cup)
Cropped cup with 2 aspect ratioic.crop(g:object,obj:cup,ar:2)
Cropped cup with 16:9 aspect ratioic.crop(g:object,obj:cup,ar:16_9)

Gravity towards (g)

Allows the user to choose the main focus of the output image.

It allows the user to select between the following options: object, foreground, face, or none. The default value is none.

If multiple items are found for the selected option, the resultant image will contain all the items. If none are found, then the original image will be returned.

Preferred direction (d)

Allows the user to select multiple preferred output image directions.

Valid values are north_west, north, north_east, west, center, east, south_west, south, and south_east. The default value is the center.

For example, in the detected object crop of a model, you want the 100x100 crop of the shoe part; changing the direction from the center to south will give a crop from the bottom; for hair, choose north, and so on.

Object type (obj)

Allows the user to choose which object to focus on.

This option is only available if the object option in the Gravity towards parameter is selected.

From including but not limited to cars, skateboards, and sheep, with over 80+ objects to choose from, gives you the crop containing your required object. If you have multiple objects in the same image, it will intelligently cover all the objects in your crop.

Open to see all available object type

airplane, apple, backpack, banana, baseball_bat, baseball_glove, bear, bed, bench, bicycle, bird, boat, book, bottle, bowl, broccoli, bus, cake, car, carrot, cat, cell_phone, chair, clock, couch, cow, cup, dining_table, dog, donut, elephant, fire_hydrant, fork, frisbee, giraffe, hair_drier, handbag, horse, hot_dog, keyboard, kite, knife, laptop, microwave, motorcycle, mouse, orange, oven, parking_meter, person, pizza, potted_plant, refrigerator, remote, sandwich, scissors, sheep, sink, skateboard, skis, snowboard, spoon, sports_ball, stop_sign, suitcase, surfboard, teddy_bear, tennis_racket, tie, toaster, toilet, toothbrush, traffic_light, train, truck, tv, umbrella, vase, wine_glass, zebra


Context API Response

info

Along with providing a transformed image, the Crop Image transformation also provides contextual information about the transformation. Go to Context to learn more.

The context response of cropping an image is a JSON, as shown below:

[
{
"name": "crop",
"operation": "IntelligentCrop",
"identifier": "ic",
"data": {
"attributes": {
"top": 47,
"left": 24,
"height": 284,
"width": 462,
"success": true,
"gravity": "object",
"direction": "center",
"target_width": null,
"target_height": null
}
},
"metadata": {...}
},
{
"name": "extract",
"operation": "Basic",
"identifier": "t",
"data": {},
"metadata": {...}
}
]

The Crop Image transformation actually just gives the bounding rectangle that encompasses the portion of the image that needs to cropped (highlighted in yellow color). The actual cropping of the image is done by the Extract transformation (highlighted in green color).

Further, the JSON keys for the attributes property are also described in the table below:

PropertyDescription
topThe distance in pixels between the top edge of the original image and the top edge of the cropped image.
leftThe distance in pixels between the left edge of the original image and the left edge of the cropped image.
heightThe height in pixels of the cropped image.
widthThe width in pixels of the cropped image.
successThe boolean value indicates whether the image has been cropped. If the value is true, the image has been effectively cropped; otherwise, it gives false.
gravityThe value entered in the Gravity towards parameter.
directionThe value entered in the Preferred direction parameter.
target_widthIf Required width is set, it will show the specified value; otherwise, it will be null.
target_heightIf Required height is set, it will show the specified value; otherwise, it will be null.
Originaloriginal
Persons Croppedic.crop(g:object,obj:person)

Example showing crop area selection

Originaloriginal
Bird Croppedic.crop(g:object,obj:bird)

Below is the corresponding Context API Response.

[
{
"name": "crop",
"operation": "IntelligentCrop",
"identifier": "ic",
"data": {
"attributes": {
"top": 204,
"left": 740,
"height": 617,
"width": 602,
"success": true,
"gravity": "object",
"direction": "center",
"target_width": null,
"target_height": null
}
},
"metadata": {...}
},
{
"name": "extract",
"operation": "Basic",
"identifier": "t",
"data": {},
"metadata": {...}
}
]

The highlighted properties are used by the Extract transformation to crop the image.

As shown, the object to crop is at a distance of 204px from the top and 740px from the left; the object's height is 617px and its width is 602px.

Bird Crop Infographic

Transform and enhance your images using our powerful AI technology. Organize your images in more efficient manner and our extensible APIs enables seamless integration with your system unleashing the power of our platform. Join the large community of users who use PixelBin to transform their image libraries and achieve excellent performance

Is this page useful?