Image

The Output Kind Image allows you to output images from Perfion.

Image

What can be output

Supports

Supported Entities

a Features (Only of type Image)

r Attributes

r Literals

a Multi value features

a Localizable features

a Output Kind Parameters

a Site

a Category

a Product

a Variant

Sample Mappings

 

 

Sample output

 

<Product id="636" ecommerceproduct="983ST">   …   <Images>     <Image name="Main Image" perfionname="Image">       <Guid>a10a14e0-7f66-4d87-8adc-a4b0e10ecf11</Guid>       <OriginalFileName>983ST_(1000x1000).png</OriginalFileName>       <Url> … Some url … </Url>     </Image>     <Image name="NewIcon" perfionname="AdditionalImages">       <Guid>a2edafa9-7f24-4dd5-a867-0a657cb58b1c</Guid>       <OriginalFileName>Coffee Accessories.jpg</OriginalFileName>       <Url> … Some url … </Url>       <ConstructedFileName>Extra-983ST.jpg</ConstructedFileName>     </Image>     <Image name="GroupImage" perfionname="GroupImage">       <Guid>149a9969-57be-48cc-ab0a-ba86641e166c</Guid>       <OriginalFileName>st364-978--mm-550.jpg</OriginalFileName>       <Url> … Some url … </Url>       <Bytes> … Base64 encoded bytes … </Bytes>       <MimeType>image/jpeg</MimeType>     </Image>   </Images> </Product>

 

Table 1: Summary of output kind Image.

Images have more data associated with them as can be seen from the Image-element output. Each image-element gives you the following:

  • Just as fields, images have a name (The value of ECommerce To in the mapping)

  • As opposed to fields, it is allowed to map multiple features to the same ECommerceTo for Output Kind Image. In case you want to distinguish which images comes from which feature the perfionname-attribute in the output holds the feature name of the mapping.

  • Images in Perfion have a Guid. That is output as a child-element of the Image-element.

  • Whenever an image is uploaded or imported into Perfion, Perfion stores its original file name. This filename is output in the OriginalFileName-element. Note that this filename is not necessarily unique. For selectable Image features, it is indeed highly likely that multiple products share the same image.

  • In settings (See chapter Settings in Ecommerce API) you can tell EC the Url to a Perfion Image Server. When this is setup EC will output the Url to the Image in the Url-element.

  • The ConstructedFileName-element is only output if you supply File as a parameter to the Image Output Kind. This is done be simply writing “Image(File)” instead of just “Image” as output kind. In addition to ‘File’ you could and should add a second parameter telling EC, how you want the filename to be constructed. This is done by adding a small filename-template where all variable parts are written between two curly brackets, i.e. { and }. Anything not in curly brackets will simply by copied as is to the ConstructedFileName-element. Between the { and } you can write any of the following:

    • Guid – Which will output the Guid for the image

    • OriginalFileName – Which will output the OriginalFileName.

    • Finally, any field-name a Field-mapping for that entity (in this case a Product) can be output. In the example above, it was the field Item No that was used. Item No is a good choice to at least have in there to ensure uniqueness. Guid can be used for the same, but Item No reads better.

The example Output Kind Image(File, ‘Extra-{Item No}’) will construct file names so that they all begin with “Extra-“ and having the Item No added. Note that ECommerceOutputKind is a selectable, so you need to add a new item to it in order to specify a filename-template.

NOTE: If no second parameter, a filename-template, is supplied the constructed file name is simply the Guid.

In settings, (see chapter Settings in Ecommerce API) you can define an OutputFolder. When done all Images output as files will be copied to that folder (in a substructure) given them their constructed file names. It is therefore important, that you ensure uniqueness of these filenames as done above using Item No as part of it. Note that setting this to blank will instruct the ECommercy Api to not store the images, but still output the ConstructedFileName-element. This is useful if you need a unique filename to pass on to the receiving system.

NOTE: No files are output when running requests from the API Tool Windows.

  • If you instead pass Embedded as parameter to the Output Kind images, EC will add a base64-encoded byte-representation of the images in a Bytes-element. Note that using this easily creates huge Xml-documents and hereby possible a performance degradation. To avoid too big results please utilize paging or filtering ensuring that not too many products are fetched simultaneously. See section GetProducts for available options on how to avoid huge result set.

In Perfion v. 4.5.36 and later you will in addition get the Mime type of the returned image.

NOTE: This Mime type depends on the format-parameter and not on the file type of the original file. Default the EC API will always return jpg-images (i.e. Mime type “image/jpeg”). See more on specifying the wanted image format in section ImageServiceUrlParameters-setting.

NOTE: The Url is reckoned as the default Output Kind parameter (“Image(Url)” and “Image” are hereby equivalent). This means that per default images will be output without constructed file names and without their bytes-representation.

You can, of course, create multiple Image-mappings on the same entity. Furthermore it is allowed to map different features to the same “To”-name in multiple mappings. This allows you to gather images from various features and have them all output by EC in the same “list”. This is not done in the mappings in Table 7, where each feature is mapped to a separate name. Mapping multiple features to the same name still allows you to distinguish the images, since the perfionname-attribute is always present and holds the name of the originating feature.