imgCrossOrigin Property

Summary

Indicates how to handle cross-origin image requests.

Syntax
TypeScript
JavaScript
Object.defineProperty(ImageLoader.prototype, 'imgCrossOrigin', 
	get: function(), 
	set: function(value) 
) 
imgCrossOrigin: string; 

Property Value

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.

Remarks

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.

ValueSend CredentialsWill 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).

Requirements

Target Platforms

Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.