Skip to main content

Creating image sizes

After a user uploads an image, Brightspot crops out various regions depending on the context. For example, in the context of an author’s bio page, the crop region is typically large; in the context of a byline, the crop region is typically small.

The easiest way to instantiate image sizes is in a theme’s configuration file _config.json; for details, see Image sizes. You can also instantiate image sizes using the classes ImageSize and ImageSizeBuilder.

Property
Description
Type
displayNameCustomized label for an image size in the image editor. In the absence of the property group, Brightspot lists image sizes first by aspect ratio, then in order of display name.String
formatSpecifies the format in which an image is delivered to the client.String
groupHeading under which an image size appears in the image editor.String
heightHeight of rendered image in web page.int
maximumHeightMaximum height of image size. Aspect ratio will be preserved by the resize at run time.int
maximumWidthMaximum width of image size. Aspect ratio will be preserved by the resize at run time.int
quality
Specifies an image’s visual quality and compression level at run time.
int
srcsetDescriptors
A list of image density or width descriptors to support different device screen resolutions. For more information, see  srcSetDescriptors.
List<String>
watermarkText appearing on top of image, often a copyright notice or attribution.Watermark
widthWidth of rendered image in web page.int

Type: Watermark

Property
Description
Type
urlThe public URL of the image to use as a watermark. Required.String
opacityThe opacity (0.0 - 1.0) of the watermark image overlay. Defaults to 1.0.Float
sizeThe percentage coverage of the watermark (0.0 - 1.0) over the original image. Defaults to 0.25.Double
position

The position of the watermark relative to the original image. Possible values are:

nw - Top Left
n - Top
ne - Top Right
w - Left
c - Center
e - Right
sw - Bottom Left
s - Bottom
se - Bottom Right

Defaults to "se".

String

Example 1: Listing image sizes by display name

ImageSize imageSize = ImageSize.builder()
.internalName("landscape-large-50x50")
.displayName("Landscape large 150x100")
.width(150)
.height(100)
.build();
  • 3. Sets the image size’s display name to Landscape large 150x100.
  • 4. Sets the image’s aspect ratio to 1.5:1 (= 150 ÷ 100). At run time, Brightspot lists all image sizes by aspect ratio in the image editor. If you have another image size with the same aspect ratio, such as 300 × 200, Brightspot lists it with all other image sizes having aspect ratio 1.5:1.

Image sizes grouped by aspect ratio

Example 2: Listing image sizes by group name

ImageSize imageSize = ImageSize.builder()
.group("Rectangles")
.width(200)
.height(100)
.build();
  • 2. Assigns this image size to a group Rectangles. At run time, Brightspot displays in the image editor only one thumbnail for all image sizes with the same group name.

Image sizes grouped by group name

See also: