if (thumb->media_type == THUMBNAIL_UTIL_IMAGE) {
if (thumb->extract_type == THUMBNAIL_UTIL_FILE) {
ret = mm_util_resize_P_P(thumb->path, thumb->width, thumb->height, thumb->thumbnail_path);
- if (ret != MM_UTIL_ERROR_NONE)
- return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+ thumbnail_util_retv_if(ret != MM_UTIL_ERROR_NONE, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION);
+
} else {
mm_util_image_h res_img = NULL;
unsigned char *buf = NULL;
mm_util_color_format_e format = MM_UTIL_COLOR_NUM;
ret = mm_util_resize_P_B(thumb->path, thumb->width, thumb->height, MM_UTIL_COLOR_BGRA, &res_img);
- if (ret != MM_UTIL_ERROR_NONE)
- return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+ thumbnail_util_retv_if(ret != MM_UTIL_ERROR_NONE, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION);
ret = mm_util_get_image(res_img, &buf, &width, &height, &buf_size, &format);
mm_util_destroy_handle(res_img);
- if (ret != MM_UTIL_ERROR_NONE)
- return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+ thumbnail_util_retv_if(ret != MM_UTIL_ERROR_NONE, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION);
+
thumb->buffer = malloc(buf_size * sizeof(unsigned char));
if (thumb->buffer != NULL) {
memcpy(thumb->buffer, buf, buf_size);
const char *supported_type = "application/vnd.ms-asf";
// Check file is existed
- if (path == NULL)
- return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
-
+ thumbnail_util_retv_if(path == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
exist = open(path, O_RDONLY);
if (exist < 0) {
thumbnail_util_error("Fail to open path[%s]", path);
char ext[255] = { 0 };
ret = __thumbnail_util_get_file_ext(path, ext, sizeof(ext));
- if (ret != THUMBNAIL_UTIL_ERROR_NONE) {
- thumbnail_util_error("__thumbnail_util_get_file_ext failed");
- return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
- }
+ thumbnail_util_retvm_if(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_get_file_ext failed");
if (strcasecmp(ext, "JPG") == 0 ||
strcasecmp(ext, "JPEG") == 0 ||
unsigned int h = 0;
ret = mm_util_extract_image_info(path, &t, &w, &h);
- if (ret != 0)
+ if (ret != 0 || t == IMG_CODEC_UNKNOWN_TYPE)
return false;
-
- if (t == IMG_CODEC_JPEG ||
- t == IMG_CODEC_PNG ||
- t == IMG_CODEC_GIF ||
- t == IMG_CODEC_BMP ||
- t == IMG_CODEC_WBMP)
- return true;
else
- return false;
+ return true;
}
int thumbnail_util_extract_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height)
thumbnail_util_media_type_e type = -1;
thumbnail_util_retvm_if(!STRING_VALID(path), THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER, "Wrong path");
- thumbnail_util_retvm_if((width > 2000 || width == 0) || (height > 2000 || width == 0), THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER, "Wrong width/height");
+ thumbnail_util_retvm_if((width > 2000 || width == 0) || (height > 2000 || height == 0), THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER, "Wrong width/height");
thumbnail_util_retvm_if(!STRING_VALID(thumbnail_path), THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER, "Wrong thumbnail_path");
/* check media type */
/* If video file, thumbnail extension is only JPEG */
if (type == THUMBNAIL_UTIL_VIDEO) {
- if (!g_str_has_suffix(thumbnail_path, ".jpg") &&
- !g_str_has_suffix(thumbnail_path, ".JPG") &&
- !g_str_has_suffix(thumbnail_path, ".jpeg") &&
- !g_str_has_suffix(thumbnail_path, ".JPEG")) {
+ char ext[255] = { 0 };
+ ret = __thumbnail_util_get_file_ext(thumbnail_path, ext, sizeof(ext));
+ thumbnail_util_retvm_if(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_get_file_ext failed");
+ if (strcasecmp(ext, "JPG") != 0 && strcasecmp(ext, "JPEG") != 0) {
thumbnail_util_error("Wrong file name[%s]", thumbnail_path);
return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}