]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8754 add ability to read high quality PDF
authorSeven Du <dujinfang@gmail.com>
Sat, 13 Feb 2016 12:14:06 +0000 (20:14 +0800)
committerSeven Du <dujinfang@gmail.com>
Thu, 17 Mar 2016 01:34:57 +0000 (09:34 +0800)
src/mod/formats/mod_imagick/mod_imagick.c

index 060889f16aa3e5c061b68a071c45fd636a7e4c96..ec74f49f0b62c1e4a5397bdf46f69e7e5162d4f3 100644 (file)
@@ -123,21 +123,11 @@ static switch_status_t imagick_file_open(switch_file_handle_t *handle, const cha
        context->image_info = AcquireImageInfo();
        switch_set_string(context->image_info->filename, path);
 
-       context->images = ReadImages(context->image_info, context->exception);
-       if (context->exception->severity != UndefinedException) {
-               CatchException(context->exception);
-       }
-
-       if (context->images == (Image *)NULL) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fail to read file: %s\n", path);
-               return SWITCH_STATUS_GENERR;
-       }
-
-       context->pagecount = GetImageListLength(context->images);
-
        if (handle->params) {
                const char *max = switch_event_get_header(handle->params, "img_ms");
                const char *autoplay = switch_event_get_header(handle->params, "autoplay");
+               const char *density = switch_event_get_header(handle->params, "density");
+               const char *quality = switch_event_get_header(handle->params, "quality");
                int tmp;
 
                if (max) {
@@ -148,8 +138,30 @@ static switch_status_t imagick_file_open(switch_file_handle_t *handle, const cha
                if (autoplay) {
                        context->autoplay = atoi(autoplay);
                }
+
+               if (density) {
+                       context->image_info->density = strdup(density);
+               }
+
+               if (quality) {
+                       tmp = atoi(quality);
+
+                       if (tmp > 0) context->image_info->quality = tmp;
+               }
+       }
+
+       context->images = ReadImages(context->image_info, context->exception);
+       if (context->exception->severity != UndefinedException) {
+               CatchException(context->exception);
        }
 
+       if (context->images == (Image *)NULL) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Fail to read file: %s\n", path);
+               return SWITCH_STATUS_GENERR;
+       }
+
+       context->pagecount = GetImageListLength(context->images);
+
        if (context->max) {
                context->samples = (handle->samplerate / 1000) * context->max;
        }