Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Doug Stevens -
Number of replies: 16

Hi all,

We are running Moodle 3.3 and are loving the PDF feedback tool. Although Unoconv has worked for all of our Doc, pdf, ppt, etc files. We are now using the Google converter for these.

Unfortunately when a student submits a photograph in the form of a jpg or png, the converter runs for a moment and then returns a blank page.  This is true of pictures and text files.

I've tried runing unoconv from the server command line on these same files and it works perfectly.  It only seems to have trouble in the PDF Feedback tool in Moodle.

Anyone else running into this?

Attachment moodlescreen.png
Average of ratings: -
In reply to Doug Stevens

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Glenn Pillsbury -

Yes, just ran into the exact same problem here with .jpg and .png files not displaying using unoconv.  PDF and .DOC(X) work fine.  Also using Moodle 3.3.

Looking for an answer...

In reply to Glenn Pillsbury

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Dale Cooper -

I found myself in a similar situation with .jpg files but .png files haven't been a issue for me.  Look at the code in $CFG->dirroot/files/converter/unoconv/classes/converter.php, there's a function called supports that is called that passes file types to is_format_supported to make sure unoconv can handle the conversion.  

What I noticed was that in the case of jpg, it was picking it up as jpe.  What ends up happening is a little bit down the line, unoconv --show is called and the list of supported filetypes it outputs is then used to see if the conversion is possible.  This list doesn't include .jpe so it ends up believing the conversion isn't possible and leaves it alone.

The quickest and dirtiest way to fix that is to insert a if statement above "return self::is_format_supported($from) && self::is_format_supported($to);" in public static function supports where if $from equals jpe then make $from equal jpg.



Average of ratings: Useful (1)
In reply to Dale Cooper

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Glenn Pillsbury -

Thanks for helping.  I just want to make sure I have the syntax correct.  So, is this what you're suggesting?

if ($from == 'jpe') {
   $from = 'jpg';
}


In reply to Glenn Pillsbury

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Glenn Pillsbury -

I just tested that addition and all jpg files seem to be processed correctly now.

Thank you!

In reply to Glenn Pillsbury

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Dale Cooper -

Happy to help!  Regarding the png files, if you throw this in:

error_log("debug $from $to",0); right above the if statement and try to view a assignment submission with a png should hopefully add a entry into whatever PHP is using for error logs (in my case it's Apache's error.log) that has what it thinks the png file format is.

With any luck, that'll give some insight with what's going on.  I've tried two different png files today and they both worked for me so I'm not sure what could be going on.

Average of ratings: Useful (1)
In reply to Dale Cooper

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Glenn Pillsbury -

It appears that .png files were not working because they had been uploaded alongside .jpg files, and the presence of .jpg files seemed to "break" the whole thing.  Once I got the .jpg type to work, .png files started displaying correctly as well. Even in combination with .docx, everything displays as expected now.

Average of ratings: Useful (1)
In reply to Glenn Pillsbury

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Doug Stevens -

Hmm... the line of code you reference doesn't seem to be in the version I have. If I "grep -iR jpe *" or "grep -iR jpg *" from dirroot/files/converter/unoconv

Any ideas?

In reply to Doug Stevens

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Glenn Pillsbury -

Hi Doug,

The file with the function in question is located at dirroot/files/converter/unoconv/classes/converter.php. Line 309.  That's where I inserted the if{} statement.

In reply to Glenn Pillsbury

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Doug Stevens -

Ah, okay was searching for the if statement.  Yup this completely solved it. Thanks!!!

In reply to Dale Cooper

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Saburo Higuchi -

Thank you for the fix.

On Moodle 3.4, the function is_format_supported($format) is called by the function start_document_conversion as well as by the function supports($from, $to). Therefore the if statement  should be inserted in the function is_format_supported($format) just before the return statement as follows.

if($format=='jpe' || $format=='jpeg'){
        $format='jpg';
}
return in_array($format, $formats);

unoconv --show returns neither jpeg nor jpe but it recognizes them.

Average of ratings: Useful (1)
In reply to Saburo Higuchi

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Michael Zwahlen -

Hi

I have the same problem when using GoogleDrive converting service. Is your solution working as well for our problem? Where do I have to change the code ?

In reply to Michael Zwahlen

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Saburo Higuchi -
Hi,

The code presented is an unoconv specific patch to ($dirroot)/files/converter/unoconv/classes/converter.php  .  I do not know whether a similar solution for the GoogleDrive converting service exists or not.


In reply to Doug Stevens

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Dirk Meyer -

Hi Doug,

we had some issues in the spring with html files, images in docx files, and others. A newer version of unoconf seems to work better.

Some ideas from developer:
- Check the unoconv status: service unoconv status or systemctl status unoconv
- Check the files in the moodledata/temp/core_files/conversions/
- Restart unoconv

Are you saying Google conversions work better for you?

In reply to Dirk Meyer

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Doug Stevens -

The issue I was having was only with JPGs. The patch above solved it.  As for the Google question, we use Google anyway for most of our students writing, so having Google doing the rendering makes it look exactly as the student intended. smile

In reply to Doug Stevens

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Jason Touw -

OK I am new to this thread and trying to read through the dialogue that has transpired, but I am not so sure that I can "fix" my issue.  I am running 3.3 on Windows Server 2012R2.  I get the blank PDF screen and I get the coding error.  Is anyone able to streamline the fix process here or is this posted somewhere on Tracker as a bug that needs to be addressed?

BLANK SCREEN:



And when I test the UNOCONV:



Note:  I do have Google OAuth and is connected to the correct account.



I did make another post in a different forum about four weeks ago with no replies, and have read the Tracker which did not seem to point me in the right direction.


Thank you!

In reply to Doug Stevens

Re: Unoconv not converting image files (jpg, png, etc) or text files for the Moodle 3.3 PDF feedback tool

by Marianne Michel -

Hello everybody.

We solved the problem (Debian 8, Moodle 3.3.1+) creating a .config file in /var/www (home directory of the user www-data) and made a chown www-data:www-data on the file.

After that, you will need to convert twice a first file.

Marianne.


Average of ratings: Useful (1)