Skip to content

Commit b8fd54d

Browse files
cli: add webp support
1 parent 38249b1 commit b8fd54d

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ A utility to create, edit, and display every type of VTF file ever made.
1717
## Features
1818

1919
- Create Mode
20-
- Directly convert animated images (APNG/GIF)
21-
- Directly convert floating point images (EXR/HDR)
20+
- Directly convert a wide range of input image formats
21+
- Animated images (APNG/GIF)
22+
- Floating point images (EXR/HDR)
23+
- Standard images (PNG/JPG/TGA/WebP)
24+
- Esoteric images (QOI/PSD/PGM/PPM/PIC/BMP)
2225
- Kaiser mipmap filtering selected by default
2326
- Create non-power of two textures
2427
- Create cubemaps from HDRIs
@@ -36,7 +39,7 @@ A utility to create, edit, and display every type of VTF file ever made.
3639
- Add, overwrite, or remove resources
3740
- Extract Mode
3841
- Save the image data contained within VTFs as image files
39-
- Save as PNG/JPEG/BMP/TGA/QOI/HDR/EXR
42+
- Save as PNG/JPEG/BMP/TGA/WebP/QOI/HDR/EXR
4043
- Defaults to PNG or EXR based on the image format
4144
- Info Mode
4245
- Print out all VTF metadata and non-image resource data
@@ -422,6 +425,7 @@ FILE_FORMAT
422425
• JPEG
423426
• BMP
424427
• TGA
428+
• WEBP
425429
• QOI
426430
• HDR
427431
• EXR

src/cli/MareTF.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ std::string_view randomDeviantArtTFTrope() {
5959
}
6060

6161
bool fileIsASupportedImageFileFormat(std::string_view extension) {
62-
static constexpr std::array<std::string_view, 14> SUPPORTED_EXTENSIONS{
62+
static constexpr std::array<std::string_view, 15> SUPPORTED_EXTENSIONS{
6363
".apng",
6464
".bmp",
6565
".exr",
@@ -74,6 +74,7 @@ bool fileIsASupportedImageFileFormat(std::string_view extension) {
7474
".psd",
7575
".qoi",
7676
".tga",
77+
".webp",
7778
};
7879
return std::ranges::find(SUPPORTED_EXTENSIONS, sourcepp::string::toLower(extension)) != SUPPORTED_EXTENSIONS.end();
7980
}
@@ -84,13 +85,14 @@ std::string_view supportedImageFileFormatExtension(vtfpp::ImageConversion::FileF
8485
case DEFAULT:
8586
// We should not be here!
8687
break;
87-
case PNG: return ".png";
88-
case JPG: return ".jpg";
89-
case BMP: return ".bmp";
90-
case TGA: return ".tga";
91-
case QOI: return ".qoi";
92-
case HDR: return ".hdr";
93-
case EXR: return ".exr";
88+
case PNG: return ".png";
89+
case JPG: return ".jpg";
90+
case BMP: return ".bmp";
91+
case TGA: return ".tga";
92+
case WEBP: return ".webp";
93+
case QOI: return ".qoi";
94+
case HDR: return ".hdr";
95+
case EXR: return ".exr";
9496
}
9597
return "";
9698
}

src/common/EnumMappings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ const std::vector<vtfpp::ImageConversion::FileFormat> IMAGE_CONVERSION_FILE_FORM
126126
vtfpp::ImageConversion::FileFormat::JPG,
127127
vtfpp::ImageConversion::FileFormat::BMP,
128128
vtfpp::ImageConversion::FileFormat::TGA,
129+
vtfpp::ImageConversion::FileFormat::WEBP,
129130
vtfpp::ImageConversion::FileFormat::QOI,
130131
vtfpp::ImageConversion::FileFormat::HDR,
131132
vtfpp::ImageConversion::FileFormat::EXR,
@@ -137,6 +138,7 @@ const std::vector<std::string_view> IMAGE_CONVERSION_FILE_FORMAT_S{
137138
"JPEG",
138139
"BMP",
139140
"TGA",
141+
"WEBP",
140142
"QOI",
141143
"HDR",
142144
"EXR",

0 commit comments

Comments
 (0)