Create image formats for specified image

Flmngr.createImageFormats

( { params } )

Creates variants for your images which are already stored in your server storage. This method does not show any UI until you change the showProgress parameter.

For example, you just uploaded an image using the Flmngr.upload({params}) method and wish to insert a preview linked to the original image. So you already have an original image and need to create a preview for it. The preview will be stored near the original image with the -preview suffix in the file name (Flmngr dialog groups all image formats in the list, so you will not have chaos in files after that).

To do this, pass all image formats you have across your app as imageFormats (if you have not already done that in Flmngr.load({params}) method) and require desired formats in createImageFormats parameter.

So, you will receive a URL of the newly generated image in onFinish callback.

Parameters

  • ...common parameters

    :
    { any parameters of Flmngr.load() method }

    All parameters that you can pass to the Flmngr.load({params}) method are also available here. So you can override some values (except apiKey) or pass parameters that were missing in the Flmngr.load() call but are required for this method, i. e. urlFiles and urlFileManager.

  • urls

    :
    string[]

    A list of URLs of images that already exist in your server storage to create other image formats.

  • createImageFormats

    :
    {[formatId: string]: string}

    A key-pair set with format IDs that you passed in the imageFormats as keys and the strategy for format creation as values.

    Possible strategies for format creation:

    • "ALWAYS"

      An image variant will be created if it does not exist, and will be forcibly refreshed even if the file already exists.

    • "DO_NOT_UPDATE"

      An image variant will be created only if its file does not exist. If there is already such a file, it will be returned in the onFinish callback. This way is useful if you wish to use a cached copy whenever it exists.

    • "IF_EXISTS"

      An image variant will be created only if its file does exist. This allows you to regenerate a preview if you have directly changed the original file via the filesystem (there is no need to do this manually after Flmngr.upload({params}) because it does the same automatically).

  • showProgress

    :
    boolean

    Set to true if you wish to have a modal progress bar on the screen while creating formats. For custom handling of progress, you can use the onProgress handler.

    Default is false. Optional

  • onFinish

    :
    (result: { [url: string]: { [formatId: string]: { url: string, width: number, height: number } } }) => void

    A callback to handle the successful creation of image variants. The result is an associative array where the keys are the urls you passed to the method, and the values are arrays of format ID - result pairs (the same format IDs you passed in createImageFormats).

    If some image can't be resized (like SVG), width and height values will be set to -1 and url will be equal to the initial passed URL of the image.

  • onProgress

    :
    (finished: number, failed: number, total: number) => void

    A listener is called every time the progress changes. It provides you with the number of processed URLs, the number of failed ones, and the percentage progress in the total argument. This callback is useful for implementing a custom progress bar in your app.

    Default is null Optional