Indicates how to handle cross-origin image requests.
A string indicating what the crossOrigin
attribute of the HTMLImageElement used in the request should be set to. The default value is 'anonymous'. Any string is acceptable, but other important values include 'use-credentials' and null.
This property is only useful with ImageLoaderUrlMode.ImageUrl. For ImageLoaderUrlMode.AjaxDataUrl or ImageLoaderUrlMode.AjaxXml, see DefaultAjaxWithCredentials and AjaxWithCredentials.
The static DefaultImgCrossOrigin is used to set the ImgCrossOrigin instance property for each new ImageLoader. The ImageLoader's ImgCrossOrigin value is the actual value used in setting the HTMLImageElement.crossOrigin
property for the WorkingImageElement.
Use the below table to understand the basic differences between these values and how they effect the resulting image. Note that these topics and implementations are from the HTML standard, not LEADTOOLS.
Value | Send Credentials | Will The Image Be Tainted? | Required Server Properties |
---|---|---|---|
null (default for HTMLImageElement) | Yes | Yes | No Required Server Properties. |
'use-credentials' | Yes | No |
The Access-Control-Allow-Origin header must be returned with the exact origin of the request. The AccessControl-Allow-Credentials header must be returned with the value true . Otherwise, the browser will reject the response. |
'anonymous' (or any other string) (default for ImageLoader) | No | No |
The Access-Control-Allow-Origin header must be returned with the exact origin of the request or the wildcard '*' . Otherwise, the browser will reject the response.
|
The default value used by ImageLoader is 'anonymous' to guarantee that the result image is not tainted so that image processing (such as interpolation) can occur on the image.
For more information on CORS, refer to Cross-Origin Resource Sharing (MDN), CORS enabled image (MDN), and CORS settings attributes (MDN).