* http://tizen.org/privilege/externalstorage is needed if input or output path points to external storage. \n
* The width and height of the thumbnail to be generated cannot exceed 2000. \n
* The width and height of the thumbnail to be generated cannot exceed the original resolution. \n
+ * Since 5.5, if the width and height of the thumbnail to be generated exceeds the original resolution, the value changes to the original resolution. \n
+ * In order to maintain the ratio, the requested size and generated size may be different. (Modify based on short axis)
*
* @param[in] path The path of the original media file
* @param[in] width The width of the thumbnail
* In the case of video file, color space of the generated thumbnail is RGB. \n
* In the case of image file, color space of the generated thumbnail is BGRA. \n
* The @a thumb_buffer should be released using free().
+ * Since 5.5, if the width and height of the thumbnail to be generated exceeds the original resolution, the value changes to the original resolution. \n
+ * In order to maintain the ratio, the requested size and generated size may be different. (Modify based on short axis)
*
* @param[in] path The path of the original media file
* @param[in] width The width of the thumbnail
SAFE_FREE(thumb);
}
+int __thumbnail_util_get_proper_thumb_size(int orig_w, int orig_h, int *thumb_w, int *thumb_h)
+{
+ bool portrait = false;
+ double ratio;
+
+ if (orig_w < orig_h)
+ portrait = true;
+
+ /* Set smaller length to default size */
+ if (portrait) {
+ if (orig_w < *thumb_w)
+ *thumb_w = orig_w;
+ ratio = (double)orig_h / (double)orig_w;
+ *thumb_h = *thumb_w * ratio;
+ } else {
+ if (orig_h < *thumb_h)
+ *thumb_h = orig_h;
+ ratio = (double)orig_w / (double)orig_h;
+ *thumb_w = *thumb_h * ratio;
+ }
+
+ thumbnail_util_debug("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
int _thumbnail_util_extract_video(thumbnail_data_s *thumb)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
int size = 0;
int width = 0;
int height = 0;
+ int thumb_width = 0;
+ int thumb_height = 0;
int cdis_value = 0;
mm_util_image_h img = NULL;
thumbnail_util_retvm_if(thumb == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER, "Data is NULL");
+ thumb_width = thumb->width;
+ thumb_height = thumb->height;
+
//1. get CDIS
ret = mm_file_create_tag_attrs(&tag, thumb->path);
if (ret == FILEINFO_ERROR_NONE) {
goto ERROR;
}
+ /* check thumb size */
+ __thumbnail_util_get_proper_thumb_size(width, height, &thumb_width, &thumb_height);
+
if (thumb->extract_type == THUMBNAIL_UTIL_FILE) {
- ret = mm_util_resize_B_P(img, thumb->width, thumb->height, thumb->thumbnail_path);
+ ret = mm_util_resize_B_P(img, thumb_width, thumb_height, thumb->thumbnail_path);
mm_util_destroy_handle(img);
if (ret != MM_UTIL_ERROR_NONE)
goto ERROR;
size_t res_buf_size = 0;
mm_util_color_format_e res_format = MM_UTIL_COLOR_NUM;
- ret = mm_util_resize_B_B(img, thumb->width, thumb->height, &res_img);
+ ret = mm_util_resize_B_B(img, thumb_width, thumb_height, &res_img);
mm_util_destroy_handle(img);
if (ret != MM_UTIL_ERROR_NONE)
goto ERROR;
int _thumbnail_util_extract(thumbnail_data_s *thumb)
{
int ret = 0;
+ unsigned int orig_width = 0;
+ unsigned int orig_height = 0;
+ int thumb_width = 0;
+ int thumb_height = 0;
+ mm_util_img_codec_type type = IMG_CODEC_UNKNOWN_TYPE;
+
thumbnail_util_retvm_if(thumb == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER, "Data is NULL");
if (thumb->media_type == THUMBNAIL_UTIL_IMAGE) {
+ thumb_width = thumb->width;
+ thumb_height = thumb->height;
+ /* Get original resolution */
+ ret = mm_util_extract_image_info(thumb->path, &type, &orig_width, &orig_height);
+ thumbnail_util_retv_if(ret != MM_UTIL_ERROR_NONE, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION);
+
+ ret = __thumbnail_util_get_proper_thumb_size((int)orig_width, (int)orig_height, &thumb_width, &thumb_height);
+ thumbnail_util_retv_if(ret != MM_UTIL_ERROR_NONE, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION);
+
if (thumb->extract_type == THUMBNAIL_UTIL_FILE) {
- ret = mm_util_resize_P_P(thumb->path, thumb->width, thumb->height, thumb->thumbnail_path);
+ ret = mm_util_resize_P_P(thumb->path, thumb_width, thumb_height, thumb->thumbnail_path);
thumbnail_util_retv_if(ret != MM_UTIL_ERROR_NONE, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION);
} else {
size_t buf_size = 0;
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);
+ ret = mm_util_resize_P_B(thumb->path, thumb_width, thumb_height, MM_UTIL_COLOR_BGRA, &res_img);
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);