Openmeetings
  1. Openmeetings
  2. OPENMEETINGS-247

Make document conversion quality an administrator changeable option

    Details

      Description

      I have the need to improve the quality of converted PDF, Word or PowerPoint files, that is increase the resolution of the conversion process for Word PDF and PowerPoint files are converted to *.swf files.

      Currently the quality of any images within converted documents is so poor that we cannot clearly read the text within the images contained in documents.

      This may be able to be resolved by allowing the quality of file conversion to be adjustable in the administration section of OpenMeeting or in the config.xml file.

      Checking the OpenMeetings log it would seem that it is using pdf2swf without any "-j" setting, I found this in the log file;
      args: [/usr/local/bin/pdf2swf, -s, insertstop, -s, poly2bitmap, -I, /user/lib/red5/webapps/openmeetings/upload/files/le8...

      Checking some of the source code I noticed that in the code these does not appear that the "-j" option is being used, therefore I guess the default value of 85% is being used when converting documents.

      -j , --jpegquality quality Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)
      zoom=<dpi> the resultion (default: 72)

      I could not find any settings in the /usr/lib/red5/webapps/openmeetings/config.xml file for the pdf2swf arguments.

      And I don't think that I can change this in OpenMeetings, it is most likely set somewhere in the source code?

      Sadly I have never managed to successfully build OpenMeetings using "ant", but checking the source code, maybe the place to add the "-j" option may be in;
      ./openmeetings/trunk/singlewebapp/src/org/openmeetings/app/documents/GenerateSWF.java line 216
      // Create the Content of the Converter Script (.bat or .sh file)

      I wonder if the developers would be able to add the "-j" option and a "-s zoom=xxx" option as a user setting, and allow this value to be adjustable by administrators?

      For example, I made the following changes so I could test the JpegQuality and zoom options;

      /singlewebapp/src/install_step1_EN.vm
      ./src/.svn/text-base/install_step1_EN.vm.svn-base

      <fieldset id="userConf1">
      <legend>Converters</legend>
      <li>
      <label for="swftools_path">SWFTools Path</label>
      <input name="swftools_path" id="swftools_path" size="27"
      title="Enter the path to swftools for example C:/swftools (Windows) or leave blank if swftools is a known to your system path" type="text" />
      <p><i>You can test if swftools is installed into system path by opening a shell or cmd-prompt and type pdf2swf<br/>
      If this shows a list of options leave this field blank otherwise you have to specify the path to pdf2swf on your system<br/>
      see also <a href="http://incubator.apache.org/openmeetings/installation.html" target="_blank">Installation</a></i></p>
      </li>
      <li>
      <label for="swftools_zoom">SWFTools Zoom</label>
      <input name="swftools_zoom" id="swftools_zoom" size="4" value="100"
      title="Enter the dpi that swftools will use for PDF to SWF conversion" type="text" />
      <p><i>You can test if swftools is installed into system path by opening a shell or cmd-prompt and type pdf2swf<br/>
      Enter the dpi that swftools will use for PDF to SWF conversion. Default is 100 dpi.<br/>
      see also <a href="http://incubator.apache.org/openmeetings/installation.html" target="_blank">Installation</a></i></p>

      </li>
      <li>
      <label for="swftools_jpegquality">SWFTools JPEG Quality</label>
      <input name="swftools_jpegquality" id="swftools_jpegquality" size="3" value="85"
      title="Enter the quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)" type="text" />
      <p>
      <i>You can test if swftools is installed into system path by opening a shell or cmd-prompt and type pdf2swf<br/>
      Enter the quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)<br/>
      see also <a href="http://incubator.apache.org/openmeetings/installation.html" target="_blank">Installation</a></i>
      </p>
      </li>

      =====================================================================================================

      ./src/org/openmeetings/app/installation/ImportInitvalues.java:298:
      ./src/org/openmeetings/app/installation/.svn/text-base/ImportInitvalues.java.svn-base:298

      cfgManagement.addConfByKey(3, "swftools_zoom", cfg.swfZoom, null,
      "dpi for conversion of PDF to SWF");

      cfgManagement.addConfByKey(3, "swftools_jpegquality", cfg.swfJpegQuality, null,
      "compression quality for conversion of PDF to SWF");

      ----------------------------------------------------------------------------------

      ./src/org/openmeetings/app/installation/InstallationConfig.java:20:
      ./src/org/openmeetings/app/installation/.svn/text-base/InstallationConfig.java.svn-base:20:
      //SWFTools PDF to SWF conversion settings
      public String swfZoom = "";
      public String swfJpegQuality = "";

      + ", mailUseTls=" + mailUseTls + ", swfZoom=" + swfZoom
      + ", swfJpegQuality=" + swfJpegQuality + ", swfPath=" + swfPath

      ----------------------------------------------------------------------------------
      ./src/org/openmeetings/servlet/outputhandler/Install.java
      ./src/org/openmeetings/servlet/outputhandler/.svn/text-base/Install.java.svn-base:245

      cfg.swfZoom = httpServletRequest.getParameter("swftools_zoom");
      cfg.swfJpegQuality = httpServletRequest.getParameter("swftools_jpegquality");

      ----------------------------------------------------------------------------------
      =====================================================================================================
      ./src/org/openmeetings/app/documents/GenerateSWF.java:
      ./src/org/openmeetings/app/documents/.svn/text-base/GenerateSWF.java.svn-base:

      private String getSwfZoom() {
      String valueForSwfZoom = cfgManagement.getConfValue("swftools_zoom", String.class, "");
      // WARNING CODE NOT COMPLETE: If SWFTools zoom (dpi) should be an integer between 50 and 600 with a default value of 100 dpi
      if (valueForSwfZoom.equals(""))

      { valueForSwfZoom = "100"; }

      return valueForSwfZoom;
      }

      private String getSwfJpegQuality() {
      String valueForSwfJpegQuality = cfgManagement.getConfValue("swftools_jpegquality", String.class, "");
      // WARNING CODE NOT COMPLETE: If SWFTools JPEG Quality should be an integer between 1 and 100, with a default value of 85
      if (valueForSwfJpegQuality.equals(""))

      { valueForSwfJpegQuality = "85"; }

      return valueForSwfJpegQuality;
      }

      public HashMap<String, String> generateSwf(String current_dir,
      String originalFolder, String destinationFolder, String fileNamePure) {

      // Create the Content of the Converter Script (.bat or .sh File)
      String[] argv = new String[]

      { getPathToSwfTools() + "pdf2swf" + execExt, "-s", "insertstop", // insert Stop command into every frame "-s","poly2bitmap", //http://www.swftools.org/gfx_tutorial.html#Rendering_pages_to_SWF_files "-i", // change draw order to reduce pdf complexity "-j", " " + getSwfJpegQuality(), // JPEG Quality to 100 "-s", " zoom=" + getSwfZoom(), // set zoom dpi to 200 originalFolder + fileNamePure + ".pdf", destinationFolder + fileNamePure + ".swf" }

      ;

      return ProcessHelper.executeScript("generateSwf", argv);
      }

      =====================================================================================================

      1. SwfToolsZoom1.diff
        14 kB
        George Kirkham
      2. zoomfix1.diff
        0.8 kB
        George Kirkham

        Activity

        Hide
        SebastianWagner added a comment -

        Hi Georg,

        I just added -j 100 to every convertion. I don't think anybody is interested in adjusting this via configuration, the resulting SWFs are pretty small anyway.

        Show
        SebastianWagner added a comment - Hi Georg, I just added -j 100 to every convertion. I don't think anybody is interested in adjusting this via configuration, the resulting SWFs are pretty small anyway.
        Hide
        George Kirkham added a comment -

        Thanks for adding the -j option, however this did not alter the quality of images in converted documents.

        Further research indicates that it may be the zoom option which affects the dpi resolution of the conversion. In a test build using a zoom value of 200 dpi and a multiply of 2 did resolve the issue. It would require further testing for me to verify that the multiply setting is not required.

        At this time I suspect that the zoom option will resolve the issue. I would find it preferable if this setting was adjustable within the OpenMeetings administrator's Configuration.

        Should I find further information about zoom or multiply parameters of swftools, I will post back in this record.

        Show
        George Kirkham added a comment - Thanks for adding the -j option, however this did not alter the quality of images in converted documents. Further research indicates that it may be the zoom option which affects the dpi resolution of the conversion. In a test build using a zoom value of 200 dpi and a multiply of 2 did resolve the issue. It would require further testing for me to verify that the multiply setting is not required. At this time I suspect that the zoom option will resolve the issue. I would find it preferable if this setting was adjustable within the OpenMeetings administrator's Configuration. Should I find further information about zoom or multiply parameters of swftools, I will post back in this record.
        Hide
        George Kirkham added a comment -

        Unfortunately the -j option did not resolve the issue. With the help of others I was able to test a new build using a zoom of 200 and a multiply of 2.

        I believe that the multiply is not required and overly increases the size of the converted file, however the zoom parameter of swftools may be of great value in increasing the resolution of the images contained in converted files.

        zoom=<dpi> the resultion (default: 72)

        It is difficult to determine the optimal value for the zoom. I had chosen 200 dpi as this is what most commonly used by fax devices, and while I like the result, I am concerned that for many people this may create an overly large swf file.

        It would be nice for the zoom parameter to be included and the value to be adjustable from within the Administrator's OpenMeetings Configuration settings.

        Thank you for your previously fast response to this request, it was greatly appreciated, and to others who have assisted me in testing the zoom parameter.

        Show
        George Kirkham added a comment - Unfortunately the -j option did not resolve the issue. With the help of others I was able to test a new build using a zoom of 200 and a multiply of 2. I believe that the multiply is not required and overly increases the size of the converted file, however the zoom parameter of swftools may be of great value in increasing the resolution of the images contained in converted files. zoom=<dpi> the resultion (default: 72) It is difficult to determine the optimal value for the zoom. I had chosen 200 dpi as this is what most commonly used by fax devices, and while I like the result, I am concerned that for many people this may create an overly large swf file. It would be nice for the zoom parameter to be included and the value to be adjustable from within the Administrator's OpenMeetings Configuration settings. Thank you for your previously fast response to this request, it was greatly appreciated, and to others who have assisted me in testing the zoom parameter.
        Hide
        George Kirkham added a comment -

        Hi, After further testing it is the zoom value which is worthwhile, however this makes files larger and so there may be a point to having both the zoom and jpegquality settings adjustable.

        To make such a change, I have identified the following possible code areas which would need changing, however as I am not familiar with OpenMeetings code, so there is a high possibility that there is more changes required (like ensuring that values are within appropriate ranges. My hope is the below information may assist with a change to the code.

        ==============================================
        ./src/install_step1_EN.vm:271:
        ./build/classes/openmeetings/install_step1_EN.vm:271:
        ./src/.svn/text-base/install_step1_EN.vm.svn-base:271:

        <label for="swftools_zoom">SWFTools Zoom</label>
        <input name="swftools_zoom" id="swftools_zoom" size="27" title="Enter the dpi that swftools will use for PDF to SWF conversion." type="text" />
        <label for="swftools_jpegquality">SWFTools JPEG quality</label>
        <input name="swftools_jpegquality" id="swftools_jpegquality" size="27" title="Enter the quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)" type="text" />

        =============================================
        ./src/org/openmeetings/app/installation/.svn/text-base/ImportInitvalues.java.svn-base:298: cfgManagement.addConfByKey(3, "swftools_zoom", cfg.swfPath, "120",
        ./src/org/openmeetings/app/installation/.svn/text-base/ImportInitvalues.java.svn-base:298: cfgManagement.addConfByKey(3, "swftools_jpegquality", cfg.swfPath, "85",

        ./src/org/openmeetings/app/installation/ImportInitvalues.java:298: cfgManagement.addConfByKey(3, "swftools_zoom", cfg.swfZoom, null,
        ./src/org/openmeetings/app/installation/ImportInitvalues.java:298: cfgManagement.addConfByKey(3, "swftools_jpegquality", cfg.swfJpegQuality, null,

        ./src/org/openmeetings/app/documents/.svn/text-base/GenerateSWF.java.svn-base:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_zoom", String.class, "");
        ./src/org/openmeetings/app/documents/.svn/text-base/GenerateSWF.java.svn-base:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_jpegquality", String.class, "");
        ./src/org/openmeetings/app/documents/GenerateSWF.java:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_zoom", String.class, "");
        ./src/org/openmeetings/app/documents/GenerateSWF.java:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_jpegquality", String.class, "");

        ./src/org/openmeetings/servlet/outputhandler/Install.java:245: cfg.swfPath = httpServletRequest.getParameter("swftools_zoom");
        ./src/org/openmeetings/servlet/outputhandler/Install.java:245: cfg.swfPath = httpServletRequest.getParameter("swftools_jpegquality");
        ./src/org/openmeetings/servlet/outputhandler/.svn/text-base/Install.java.svn-base:245: cfg.swfPath = httpServletRequest.getParameter("swftools_zoom");
        ./src/org/openmeetings/servlet/outputhandler/.svn/text-base/Install.java.svn-base:245: cfg.swfPath = httpServletRequest.getParameter("swftools_jpegquality");
        =============================================

        Show
        George Kirkham added a comment - Hi, After further testing it is the zoom value which is worthwhile, however this makes files larger and so there may be a point to having both the zoom and jpegquality settings adjustable. To make such a change, I have identified the following possible code areas which would need changing, however as I am not familiar with OpenMeetings code, so there is a high possibility that there is more changes required (like ensuring that values are within appropriate ranges. My hope is the below information may assist with a change to the code. ============================================== ./src/install_step1_EN.vm:271: ./build/classes/openmeetings/install_step1_EN.vm:271: ./src/.svn/text-base/install_step1_EN.vm.svn-base:271: <label for="swftools_zoom">SWFTools Zoom</label> <input name="swftools_zoom" id="swftools_zoom" size="27" title="Enter the dpi that swftools will use for PDF to SWF conversion." type="text" /> <label for="swftools_jpegquality">SWFTools JPEG quality</label> <input name="swftools_jpegquality" id="swftools_jpegquality" size="27" title="Enter the quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)" type="text" /> ============================================= ./src/org/openmeetings/app/installation/.svn/text-base/ImportInitvalues.java.svn-base:298: cfgManagement.addConfByKey(3, "swftools_zoom", cfg.swfPath, "120", ./src/org/openmeetings/app/installation/.svn/text-base/ImportInitvalues.java.svn-base:298: cfgManagement.addConfByKey(3, "swftools_jpegquality", cfg.swfPath, "85", ./src/org/openmeetings/app/installation/ImportInitvalues.java:298: cfgManagement.addConfByKey(3, "swftools_zoom", cfg.swfZoom, null, ./src/org/openmeetings/app/installation/ImportInitvalues.java:298: cfgManagement.addConfByKey(3, "swftools_jpegquality", cfg.swfJpegQuality, null, ./src/org/openmeetings/app/documents/.svn/text-base/GenerateSWF.java.svn-base:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_zoom", String.class, ""); ./src/org/openmeetings/app/documents/.svn/text-base/GenerateSWF.java.svn-base:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_jpegquality", String.class, ""); ./src/org/openmeetings/app/documents/GenerateSWF.java:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_zoom", String.class, ""); ./src/org/openmeetings/app/documents/GenerateSWF.java:46: String pathToSWFTools = cfgManagement.getConfValue("swftools_jpegquality", String.class, ""); ./src/org/openmeetings/servlet/outputhandler/Install.java:245: cfg.swfPath = httpServletRequest.getParameter("swftools_zoom"); ./src/org/openmeetings/servlet/outputhandler/Install.java:245: cfg.swfPath = httpServletRequest.getParameter("swftools_jpegquality"); ./src/org/openmeetings/servlet/outputhandler/.svn/text-base/Install.java.svn-base:245: cfg.swfPath = httpServletRequest.getParameter("swftools_zoom"); ./src/org/openmeetings/servlet/outputhandler/.svn/text-base/Install.java.svn-base:245: cfg.swfPath = httpServletRequest.getParameter("swftools_jpegquality"); =============================================
        Hide
        SebastianWagner added a comment -

        Your implementation does not really set the value in the convertion itself, it just adds the configuration possibility.
        Could you please create a regular patch file by using svn diff?

        Show
        SebastianWagner added a comment - Your implementation does not really set the value in the convertion itself, it just adds the configuration possibility. Could you please create a regular patch file by using svn diff?
        Hide
        George Kirkham added a comment -

        Diff file for changes allowing Zoom and Quality to be administrator adjustable values

        Show
        George Kirkham added a comment - Diff file for changes allowing Zoom and Quality to be administrator adjustable values
        Hide
        SebastianWagner added a comment -

        I have committed your patch

        Show
        SebastianWagner added a comment - I have committed your patch
        Hide
        George Kirkham added a comment -

        Apologies, there was a fault in the diff file that I uploaded. It contained two spaces with must not exist.

        I will attach a new diff file which corrects these two errors.

        Thanks,

        George Kirkham

        Show
        George Kirkham added a comment - Apologies, there was a fault in the diff file that I uploaded. It contained two spaces with must not exist. I will attach a new diff file which corrects these two errors. Thanks, George Kirkham
        Hide
        George Kirkham added a comment -

        Apologies, there was a fault in the diff file that I uploaded. It contained two spaces with must not exist, these spaces stop the parameters from taking effect.
        + "-j", "" + getSwfJpegQuality(), // JPEG Quality
        + "-s", "zoom=" + getSwfZoom(), // set zoom dpi

        I have attached the new diff file, zoomfix1.diff, which corrects these two errors.

        Thanks,

        George Kirkham

        Show
        George Kirkham added a comment - Apologies, there was a fault in the diff file that I uploaded. It contained two spaces with must not exist, these spaces stop the parameters from taking effect. + "-j", "" + getSwfJpegQuality(), // JPEG Quality + "-s", "zoom=" + getSwfZoom(), // set zoom dpi I have attached the new diff file, zoomfix1.diff, which corrects these two errors. Thanks, George Kirkham
        Hide
        SebastianWagner added a comment -

        Committed, please check if that revision is working for you too.
        Thanks
        Sebastian

        Show
        SebastianWagner added a comment - Committed, please check if that revision is working for you too. Thanks Sebastian
        Hide
        George Kirkham added a comment -

        Changes are now working

        Show
        George Kirkham added a comment - Changes are now working

          People

          • Assignee:
            Unassigned
            Reporter:
            George Kirkham
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development