Improve handling of supported image formats and file extensions, Update README with more information about supported formats
This commit is contained in:
parent
8a53cc48b0
commit
efc0c1cc72
4 changed files with 31 additions and 13 deletions
|
@ -24,6 +24,15 @@ You can find the latest release ...
|
|||
- [here (remotebranch.eu)](https://remotebranch.eu/ChaoticByte/Pigment/releases/latest)
|
||||
|
||||
|
||||
## Supported Image Formats
|
||||
|
||||
| Format | Import | Export | Notes |
|
||||
| ------ | :----: | :----: | ----- |
|
||||
| PNG | ✔ | ✔ | exports to 8-bit RGBA |
|
||||
| JPEG | ✔ | | |
|
||||
| WEBP | ✔ | | |
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
With Pigment, you process images by writing Shader code using Godot's GLSL dialect: GDShader.
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
extends Node
|
||||
|
||||
const SUPPORTED_INPUT_EXT = [
|
||||
".jpeg", ".jpg", ".png", ".webp"
|
||||
]
|
||||
|
||||
var cwd = "."
|
||||
|
||||
var shader_path = "":
|
||||
|
@ -31,16 +35,22 @@ func get_absolute_path(p: String) -> String:
|
|||
return p
|
||||
|
||||
func load_image() -> String: # returns an error message
|
||||
print("Load ", input_image_path)
|
||||
var supported = false
|
||||
for e in SUPPORTED_INPUT_EXT:
|
||||
if self.input_image_path.ends_with(e):
|
||||
supported = true
|
||||
if not supported:
|
||||
return "File extension not supported."
|
||||
print("Load ", self.input_image_path)
|
||||
var img = Image.new()
|
||||
var err = img.load(input_image_path)
|
||||
var err = img.load(self.input_image_path)
|
||||
if err == OK:
|
||||
input_image_texture = ImageTexture.create_from_image(img)
|
||||
if self.last_image_savepath == "" or input_image_path != self.last_input_image_path:
|
||||
self.last_image_savepath = input_image_path
|
||||
self.last_input_image_path = input_image_path
|
||||
if self.last_image_savepath == "" or self.input_image_path != self.last_input_image_path:
|
||||
self.last_image_savepath = self.input_image_path
|
||||
self.last_input_image_path = self.input_image_path
|
||||
return ""
|
||||
return error_string(err) + " " + input_image_path
|
||||
return error_string(err) + " " + self.input_image_path
|
||||
|
||||
func save_result(path: String):
|
||||
print("Export ", path)
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
extends Node
|
||||
|
||||
const BATCH_MODE_SUPPORTED_EXTS = [
|
||||
".bmp", ".dds", ".exr", ".hdr", ".jpeg", ".jpg", ".ktx", ".png", ".svg", ".webp"
|
||||
]
|
||||
|
||||
@onready var app_name = ProjectSettings.get_setting("application/config/name")
|
||||
|
||||
func show_help():
|
||||
|
@ -75,7 +71,7 @@ func cli(args: PackedStringArray):
|
|||
var out_dir_path: String = kwargs["--output"].rstrip("/")
|
||||
for f in load_image_dir.get_files():
|
||||
var supported = false
|
||||
for e in BATCH_MODE_SUPPORTED_EXTS:
|
||||
for e in Filesystem.SUPPORTED_INPUT_EXT:
|
||||
if f.ends_with(e):
|
||||
supported = true
|
||||
break
|
||||
|
|
|
@ -26,7 +26,7 @@ enum Status {OKAY, ERROR, UNKNOWN = -1}
|
|||
|
||||
func _ready() -> void:
|
||||
var exts = []
|
||||
for e in main.BATCH_MODE_SUPPORTED_EXTS:
|
||||
for e in Filesystem.SUPPORTED_INPUT_EXT:
|
||||
exts.append("*" + e)
|
||||
open_image_dialog.add_filter(", ".join(exts), "Image")
|
||||
open_shader_dialog.add_filter("*.gdshader", "Shader")
|
||||
|
@ -74,7 +74,10 @@ func _on_apply_shader_button_pressed():
|
|||
func _on_save_image_button_pressed():
|
||||
if Filesystem.result != null:
|
||||
set_buttons_disabled(true)
|
||||
save_image_dialog.current_path = Filesystem.last_image_savepath
|
||||
var p = Filesystem.last_image_savepath
|
||||
for ext in Filesystem.SUPPORTED_INPUT_EXT:
|
||||
p = p.trim_suffix(ext)
|
||||
save_image_dialog.current_path = p + ".png"
|
||||
save_image_dialog.show()
|
||||
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue