diff --git a/core/image.cpp b/core/image.cpp
index ff4937527f5..9a977a9d80a 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -2113,6 +2113,8 @@ Error Image::decompress() {
 }
 
 Error Image::compress(CompressMode p_mode, CompressSource p_source, float p_lossy_quality) {
+	ERR_FAIL_INDEX_V_MSG(p_mode, COMPRESS_MAX, ERR_INVALID_PARAMETER, "Invalid compress mode.");
+	ERR_FAIL_INDEX_V_MSG(p_source, COMPRESS_SOURCE_MAX, ERR_INVALID_PARAMETER, "Invalid compress source.");
 	switch (p_mode) {
 		case COMPRESS_S3TC: {
 			ERR_FAIL_COND_V(!_image_compress_bc_func, ERR_UNAVAILABLE);
@@ -2138,6 +2140,9 @@ Error Image::compress(CompressMode p_mode, CompressSource p_source, float p_loss
 			ERR_FAIL_COND_V(!_image_compress_bptc_func, ERR_UNAVAILABLE);
 			_image_compress_bptc_func(this, p_lossy_quality, p_source);
 		} break;
+		case COMPRESS_MAX: {
+			ERR_FAIL_V(ERR_INVALID_PARAMETER);
+		} break;
 	}
 
 	return OK;
diff --git a/core/image.h b/core/image.h
index c03b8982408..b54664c0afb 100644
--- a/core/image.h
+++ b/core/image.h
@@ -124,6 +124,7 @@ public:
 		COMPRESS_SOURCE_SRGB,
 		COMPRESS_SOURCE_NORMAL,
 		COMPRESS_SOURCE_LAYERED,
+		COMPRESS_SOURCE_MAX,
 	};
 
 	//some functions provided by something else
@@ -304,7 +305,8 @@ public:
 		COMPRESS_PVRTC4,
 		COMPRESS_ETC,
 		COMPRESS_ETC2,
-		COMPRESS_BPTC
+		COMPRESS_BPTC,
+		COMPRESS_MAX,
 	};
 
 	Error compress(CompressMode p_mode = COMPRESS_S3TC, CompressSource p_source = COMPRESS_SOURCE_GENERIC, float p_lossy_quality = 0.7);
diff --git a/modules/pvr/image_compress_pvrtc.cpp b/modules/pvr/image_compress_pvrtc.cpp
index 4c67bb7a294..196026cf401 100644
--- a/modules/pvr/image_compress_pvrtc.cpp
+++ b/modules/pvr/image_compress_pvrtc.cpp
@@ -43,6 +43,10 @@ static void _compress_pvrtc4(Image *p_img) {
 	if (!img->is_size_po2() || img->get_width() != img->get_height()) {
 		make_mipmaps = img->has_mipmaps();
 		img->resize_to_po2(true);
+		// Resizing can fail for some formats
+		if (!img->is_size_po2() || img->get_width() != img->get_height()) {
+			ERR_FAIL_MSG("Failed to resize the image for compression.");
+		}
 	}
 	img->convert(Image::FORMAT_RGBA8);
 	if (!img->has_mipmaps() && make_mipmaps) {