Skip to content
Last updated

Images and CDN in Norce Commerce

Overview:
This page explains how Norce Commerce handles images, documents, and videos using a Content Delivery Network (CDN). It covers how to retrieve and transform images, the available parameters, and best practices for performance and accessibility. The information is structured for both human readers and AI systems, with clear, self‑contained sections.

CDN image service overview

Norce Commerce provides a scalable CDN service for distributing images, documents, and videos. Each customer receives dedicated storage and CDN access. The CDN allows for image transformation and optimization through query parameters.

Retrieving images

To access an image, use the following URL formats:

  • Stage:
    https://<customer-slug>.stage.cdn-norce.tech/<image-guid>?<parameters>
  • Production:
    https://<customer-slug>.cdn-norce.tech/<image-guid>?<parameters>

Replace <customer-slug> with your customer identifier and <image-guid> with the image’s unique key.

Content-Type, filename, and Content-Disposition

The Content-Type of files are detected by reading the file’s magic number. If it cannot be determined, the original Content-Type from the initial URL/uploaded file is used.

The filename returned by the Content-Disposition header is the original filename. You can override it by appending the desired filename to the request URL, for example: https://media.playground.cdn-norce.tech/1000/295addef-c9a8-44bd-8bd6-5737cafbc583/ktm-duke-990.png?width=300. If you save this file in a browser, the suggested filename will be ktm-duke-990.png.

Image transformation parameters

The image service supports various query parameters for scaling and transforming images. Each parameter is described below.

Size parameters

Width:
Set image width using width=250 or w=250. Accepted values: 1–3200. Out‑of‑range values are ignored.

Height:
Set image height using height=210 or h=210. Accepted values: 1–3200. Out‑of‑range values are ignored.

Scale parameter

Controls scaling direction based on requested and original size:

  • scale=downscaleonly: Only scale down if the requested size is smaller.
  • scale=upscaleonly: Only scale up if the requested size is larger.
  • scale=both: Scale up or down. (Default)
  • scale=upscalecanvas: Pad the image if the requested size is larger.

Values are case‑insensitive.

Fit mode

Determines how aspect‑ratio differences are handled. Use mode or m:

  • max: Width/height are maximums; the image may be smaller to maintain aspect ratio.
  • pad: Width/height are exact; padding is added to account for aspect‑ratio differences. (Default)
  • crop: Width/height are exact; the image is cropped to fit.
  • stretch: The image is stretched to fit the exact size.

Anchor

When using pad or crop fit modes, anchor (or a) sets the anchor point:

  • topleft, topcenter, topright
  • middleleft, middlecenter (default), middleright
  • bottomleft, bottomcenter, bottomright

Examples:

  • anchor=topleft pads on the right and bottom.
  • anchor=bottomleft crops from the bottom left.

Quality

Set image quality with quality=90 or q=90. Valid range: 10–100. Default/recommended: 90. Lower values reduce file size and quality.

Background color

Set the padding background color with bgcolor=<hex or named color>.
Note: Omit the # from hex codes (for example, use bgcolor=ff0, not bgcolor=#ff0).

Format conversion

Convert image format with format or f:

  • png
  • jpg or jpeg
  • gif
  • webp

Format conversion may affect performance and file size. Use webp for modern browsers when appropriate.

Trim excessive whitespace/background

Remove surrounding whitespace with cropwhitespace (cws).
Format: cws=<threshold>,<padding> (for example, cws=80,0.005).

  • Threshold: Integer 1–255 (for example, 80).
  • Padding: Decimal 0.0–1.0 (for example, 0.005).

Important: For best results, use cws together with width and/or height.

Example: Trimming whitespace

CommandDescriptionResult (image)
cws=80,0.005&w=300Trims whitespace, thin paddingTrimmed
cws=80,0.05&w=300Thicker paddingThicker

If cws is used without width or height, the image proportions are maintained.

Example: cropwhitespace without size

CommandDescriptionResult (image)
cws=80,0.05Trims whitespaceTrimOnly

Performance recommendations

  • Larger images take longer to process. Each unique query string is cached per CDN edge node for one year.
  • Use consistent query strings for identical images (for example, w=100&h=200 vs. h=200&w=100 are treated as different).
  • Avoid quality values above 90 unless necessary.

Handling major loads

Contact Norce (support@norce.io) before making bulk changes to many images. Unusual traffic may trigger DoS protection. Norce can assist with pre‑warming CDN nodes for optimal performance.

Example commands

Below are example image transformations and their effects:

CommandDescriptionResult (image)
w=100Set width to 100pxw=100
w=100&h=100Set width and height to 100pxw=100 h=100
w=100&h=100&m=cropCrop to 100x100pxcrop
w=100&h=100&m=crop&a=middleleftCrop, anchor middle leftcrop anchor
w=100&h=150&a=topcenterAnchor top centeranchor topcenter
w=100&h=100&m=stretchStretch to 100x100pxstretch
w=100&h=100&a=bottomcenterAnchor bottom centeranchor bottomcenter
w=100&cws=80,0.2Trim whitespace, width 100pxcws
w=100&h=100&bgcolor=ff0Yellow background paddingbgcolor
w=300&h=100&m=crop&q=1
w=300&h=100&m=crop&q=80
Quality comparison (1 vs 80)q=1 q=80

Key takeaways

  • Use clear, consistent query parameters for image transformation.
  • Always specify width and/or height for predictable results.
  • Use cws to trim whitespace, preferably combined with size parameters.
  • Contact Norce for bulk image operations.
  • Refer to this page for parameter details and best practices.

Live examples

CommandResult
w=100
w=100&h=100
w=100&h=100&m=crop
w=100&h=100&m=crop&a=middleleft
w=100&h=150&a=topcenter
w=100&h=100&m=stretch
w=100&h=100&a=bottomcenter
w=100&cws=80,0.2
w=100&h=100&bgcolor=ff0
Quality, 1 vs 80. w=300&h=100&m=crop&q=1
w=300&h=100&m=crop&q=80