{ let reader = new FileReader(); reader.onload = (event) => { let originalImageUrl = `${event.target.result}`; const img = new Image(); img.src = originalImageUrl; img.onload = function () { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); // Calculate the aspect ratio of the image const aspectRatio = img.width / img.height; // Calculate the new width and height to fit within 100x100 let newWidth, newHeight; if (aspectRatio > 1) { newWidth = 100 * aspectRatio; newHeight = 100; } else { newWidth = 100; newHeight = 100 / aspectRatio; } // Set the canvas size canvas.width = 100; canvas.height = 100; // Calculate the position to center the image const offsetX = (100 - newWidth) / 2; const offsetY = (100 - newHeight) / 2; // Draw the image on the canvas ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight); // Get the base64 representation of the compressed image const compressedSrc = canvas.toDataURL('image/jpeg'); // Display the compressed image imageUrl = compressedSrc; inputFiles = null; }; }; if ( inputFiles && inputFiles.length > 0 && ['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type']) ) { reader.readAsDataURL(inputFiles[0]); } else { console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`); inputFiles = null; } }} />
My Modelfiles
{ history.back(); }} >
Back
{ submitHandler(); }} >
{ filesInputElement.click(); }} > {#if imageUrl}
{:else}
{/if}
Name*
Model Tag Name*
Description*
Modelfile
{ raw = !raw; }} > {#if raw}
Raw Format
{:else}
Builder Mode
{/if}
{#if raw}
Content*
Not sure what to write? Switch to
{ raw = !raw; }}>Builder Mode
or
Click here to check other modelfiles.
{:else}
From (Base Model)*
To access the available model names for downloading,
click here.
System Prompt
Modelfile Advanced Settings
{ advanced = !advanced; }} > {#if advanced}
Custom
{:else}
Default
{/if}
{#if advanced}
Template
Parameters
{/if} {/if}
Prompt suggestions
{ if (suggestions.length === 0 || suggestions.at(-1).content !== '') { suggestions = [...suggestions, { content: '' }]; } }} >
{#each suggestions as prompt, promptIdx}
{ suggestions.splice(promptIdx, 1); suggestions = suggestions; }} >
{/each}
Categories
{#each Object.keys(categories) as category}
{category}
{/each}
{#if pullProgress !== null}
Pull Progress
{pullProgress ?? 0}%
{digest}
{/if}
Save & Create
{#if loading}
{/if}