Merge pull request #907 from ogmaresca/webp-support

Support WEBP image formats
This commit is contained in:
cmdr2 2023-02-20 18:36:40 +05:30 committed by GitHub
commit 50e4683492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 8 deletions

View File

@ -39,7 +39,7 @@ class TaskData(BaseModel):
show_only_filtered_image: bool = False
block_nsfw: bool = False
output_format: str = "jpeg" # or "png"
output_format: str = "jpeg" # or "png" or "webp"
output_quality: int = 75
metadata_output_format: str = "txt" # or "json"
stream_image_progress: bool = False

View File

@ -223,9 +223,10 @@
<select id="output_format" name="output_format">
<option value="jpeg" selected>jpeg</option>
<option value="png">png</option>
<option value="webp">webp</option>
</select>
</td></tr>
<tr class="pl-5" id="output_quality_row"><td><label for="output_quality">JPEG Quality:</label></td><td>
<tr class="pl-5" id="output_quality_row"><td><label for="output_quality">Image Quality:</label></td><td>
<input id="output_quality_slider" name="output_quality" class="editor-slider" value="75" type="range" min="10" max="95"> <input id="output_quality" name="output_quality" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)">
</td></tr>
</table></div>

View File

@ -2,7 +2,7 @@
const EXT_REGEX = /(?:\.([^.]+))?$/
const TEXT_EXTENSIONS = ['txt', 'json']
const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'bmp', 'tiff', 'tif', 'tga']
const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'bmp', 'tiff', 'tif', 'tga', 'webp']
function parseBoolean(stringValue) {
if (typeof stringValue === 'boolean') {

View File

@ -1127,7 +1127,7 @@ function createFileName(prompt, seed, steps, guidance, outputFormat) {
// fileName += `${tagString}`
// add the file extension
fileName += '.' + (outputFormat === 'png' ? 'png' : 'jpeg')
fileName += '.' + outputFormat
return fileName
}
@ -1303,7 +1303,7 @@ function updateHypernetworkStrengthContainer() {
hypernetworkModelField.addEventListener('change', updateHypernetworkStrengthContainer)
updateHypernetworkStrengthContainer()
/********************* JPEG Quality **********************/
/********************* JPEG/WEBP Quality **********************/
function updateOutputQuality() {
outputQualityField.value = 0 | outputQualitySlider.value
outputQualityField.dispatchEvent(new Event("change"))
@ -1325,10 +1325,10 @@ outputQualityField.addEventListener('input', debounce(updateOutputQualitySlider,
updateOutputQuality()
outputFormatField.addEventListener('change', e => {
if (outputFormatField.value == 'jpeg') {
outputQualityRow.style.display='table-row'
} else {
if (outputFormatField.value === 'png') {
outputQualityRow.style.display='none'
} else {
outputQualityRow.style.display='table-row'
}
})

View File

@ -31,6 +31,7 @@ const PLUGINS = {
OUTPUTS_FORMATS: new ServiceContainer(
function png() { return (reqBody) => new SD.RenderTask(reqBody) }
, function jpeg() { return (reqBody) => new SD.RenderTask(reqBody) }
, function webp() { return (reqBody) => new SD.RenderTask(reqBody) }
),
}
PLUGINS.OUTPUTS_FORMATS.register = function(...args) {