Unoconv not converting jpeg to PDF

Re: Atbilde: Unoconv not converting jpeg to PDF

by Ken Task -
Number of replies: 2
Picture of Particularly helpful Moodlers

unoconv doesn't support .jpeg ... but does support .jpg

.jpeg files are not .jpg's.

So ... you could try the following ...

Use the following mysql query to find where these .jpeg files are located in
the sea of files in moodledata/filedir/

mysql> select contenthash,filename from mdl_files where filename like '%.jpeg';

The contenthash value can be used to find the file in moodledata/filedir/
from command line.

cd /path/to/moodledata/filedir/
find ./ -name [contenthash]

That will take some time to run but one will see something like:
/xx/yy/contenthash

To make sure it's the right mime type:

file -b /xx/yy/contenthash

Ok, now the tricky parts ....

*copy* the /xx/yy/contenthash out of moodledata/filedir/ and put that copy
out to a web accessible directory (in this example, /var/www/html/img2convert/

cp /xx/yy/contenthash /var/www/html/img2convert/[filename].jpeg

Download and use local app to convert to .jpg

Or if you have imagemagick installed could try:

convert filename.jpeg filename.jpg

Upload the converted [filename].jpg to /var/www/html/imgconverted/

Or if imagemagick worked, cp the converted .jpg using below

From /var/www/html/imgconverted/ directory copy and replace the old contenthash name file:

cp [filename].jpg /path/to/moodledata/filedir//xx/yy/contenthash

From /var/www/html/imgconverted/ directory copy and replace the old contenthash name file:

cp [filename].jpg /path/to/moodledata/filedir//xx/yy/contenthash

In the DB mdl_files change filename from .jpeg to .jpg

now go to whatever to see if assignment can convert the file to pdf.

Fingers crossed!

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Atbilde: Re: Atbilde: Unoconv not converting jpeg to PDF

by Kristaps Muižnieks -
Hey!

Thanks for reply. This seems long way but must be tried.

So the only way to deal with jpegs is to restrict uploads by restricting students to upload non jpeg pictures? I have seen that there was some trick in old version of Moodle by changing file extension in the core files.
In reply to Kristaps Muižnieks

Re: Atbilde: Re: Atbilde: Unoconv not converting jpeg to PDF

by Ken Task -
Picture of Particularly helpful Moodlers

If you'll check assigment set up there is a mimetype (filestype) restriction one can set.   Students can only upload those.   No .jpeg for obvious reasons.

'some trick' that was then, cause just changing a file name extension doesn't change internals of a file ... any file ... any operating system ... any application.

'SoS', Ken