Massive clean up of PGalias.pm and PGresource.pm.#1046
Massive clean up of PGalias.pm and PGresource.pm.#1046Alex-Jordan merged 2 commits intoopenwebwork:developfrom
Conversation
a4d6a10 to
e189246
Compare
a7d4c27 to
1808683
Compare
|
While testing, I was looking for different resources to make sure everything is loading correctly. This problem: I'm guessing this needs to be converted to PDF for latex hardcopy. Since has the same behavior on both develop and this branch, this may not be relevant for this, but should be fixed. |
|
Actually, since the |
|
I'm not seeing the same error, but |
|
Just tested on ubuntu and the image isn't being converted. Just tested another svg file and the same result. |
|
What svg are you using? Maybe it is not a valid svg file to being with. |
|
I tested the one in the problem cited above and also tested the |
|
On Ubuntu those files convert fine for me. Don't know why it wouldn't work for you. Have you tested from the command line? |
843e301 to
b13a22e
Compare
|
Trying to convert the flower svg to png using If I do Maybe you can't see it in GitHub, but if you click to see that image, I do see two white dots surrounded by no background. Those dots correspond to dots in the original svg, but the rest of the image is missing. Over on my development server (Oracle 8.7) the ImageMagick version is 6.9.12-77. There, if I run |
|
I know the switch to imagemagick 7 has changed lots of things. My very limited understanding is imagemagick 7 now uses a single binary We may need to detect for (or have a setting for) systems that use imagemagick 7, and adjust commands appropriately. |
|
@Alex-Jordan, does running https://imagemagick.org/script/convert.php With svg files we may need to also specify the size of the image? |
|
Unfortunately `magick flower_with_2_leaves_and_3_petals.svg
flower_with_2_leaves_and_3_petals.png` on the Mac did not change things.
I uploaded that svg to the validator at https://validator.w3.org, and it
validates, but with two warnings:
* This validator does not validate Inkscape extensions properly.
Inkscape-specific errors may go unnoticed.
* This validator does not validate RDF. RDF subtrees go unchecked.
Unsure if these are relevant.
…On Fri, Apr 5, 2024 at 10:23 AM Jaimos Skriletz ***@***.***> wrote:
@Alex-Jordan
<https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3132feb7-454455534531-8c34945460626b92&q=1&e=b3538120-e155-44dc-aa11-42abed6a71b5&u=https%3A%2F%2Fgithub.com%2FAlex-Jordan>,
does running magick image.svg image.png work on the system with
imagemagick 7?
https://imagemagick.org/script/convert.php
—
Reply to this email directly, view it on GitHub
<https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3132feb7-454455534531-0acfdd79cdeb9a91&q=1&e=b3538120-e155-44dc-aa11-42abed6a71b5&u=https%3A%2F%2Fgithub.com%2Fopenwebwork%2Fpg%2Fpull%2F1046%23issuecomment-2040296185>,
or unsubscribe
<https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3132feb7-454455534531-f6f23d12017a05a0&q=1&e=b3538120-e155-44dc-aa11-42abed6a71b5&u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABEDOAEDJKIJGBS3S2JTUTLY33MW7AVCNFSM6AAAAABFJI7Z3GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBQGI4TMMJYGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Alex Jordan
Mathematics Instructor
Portland Community College
|
|
Lost a comment in my ninja edit, does adding |
|
No visible changes with either of those options.
…On Fri, Apr 5, 2024 at 10:31 AM Jaimos Skriletz ***@***.***> wrote:
Lost a comment in my ninja edit, does adding -size 250x250 or maybe -size 250x250 canvas:none help?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
--
Alex Jordan
Mathematics Instructor
Portland Community College
|
|
Looking a bit deeper, it seems that imagemagick 7 uses one of {MSVG|InkScape|RSVG} to render svgs, and the one being used is dependent on build time options. You should be able to add a |
|
I get this: |
|
Well it does appear that binary is using inkscape, which is one of the validation errors you got. If you test with an .svg that passes the inkscape validation, things work? |
|
I removed all But still, when I run |
|
@somiaj: There will be no need for a switch to detect whether to use In any case, at least LaTeX will succeed in generating a PDF with this change if an svg image is in the probelm (even if a later version of imagemagick isn't working right). With the develop branch, it just fails. If someone using imagemagick 7 can investigate and see what is wrong there, then we can look into a fix. |
|
I was looking into this a few days ago and see the same things as @Alex-Jordan. One thing that worked for me was to use the rvsg library to do the conversion. I can't seem to find the site that I found this, but in the and then on the convert, I prefixed and the image converted correctly. You can also use I may have needed to install the rsvg code instead. I didn't get to the point to get WW/PG to do use this yet. |
That is interesting. On Ubuntu with ImageMagick 6, the file |
|
The file also has the line |
|
I also don't think that the svg conversion issues should be a stopper for this pull request. As I mentioned the current status of hardcopy generation with an svg is failure anyway. The svg conversion was added as an afterthought to this pull request, and the other aspects of this are more important than that. |
b13a22e to
212b632
Compare
212b632 to
3a97a55
Compare
|
I did some more testing on this and I see that ImageMagick does use the lines in the I discovered that if I have the version of Note that this is all with ImageMagick version 6.9.11. So the conclusion is that the conversion issues are not related to the version of ImageMagick, but are related to the set up and the availability of inkscape, and it being configured correctly in the delegates.xml file. In the delegates file, it should not have "decode=rsvg", it should be "delegates=svg". Note that snap version of inkscape can not even open a file from the command line, and that is the reason things fail with that. That is all just the stupidity of snaps. If you are using ImageMagick version 7, then you just set the external program to be So this is not an issue with how this is set up with the code in PG as implemented in this pull request. It is an issue with documenting how to set up ImageMagick and inkscape on systems so that it will work. On Ubuntu it is as simple as installing inkscape from the apt repository instead of the snap. It sounds like on OSX the delegates file will need to be amended. |
|
By the way, note that this does depend on the svg too. Regardless of which inkscape is installed, the |
fb8050c to
b13533d
Compare
b13533d to
d592110
Compare
Rewrite the PGalias.pm and PGresource.pm files so that the implemenation makes much more sense and doesn't have the massive kludge that they were. The behavior is the same as it was. The structure of the data stored in a PGresource object is different (all of the things that were only used internally by PGalias are no longer there), and a minor change to webwork2 is needed to accomodate for that cchange. There is one change of note. This switches PGalias.pm from using the "gif2png" external program to using the "convert" external program to convert gif files to png files. Note that the "giv2png" external program is "/usr/bin/giftopnm" by default. Of course "convert" is imagemagick's convert utility. This works just as well (if not better). Note that an animated gif is converted to the first frame (same as before). Note that "csv" files are also added to the list of allowed auxiliary resources. At this point this is not used, but the rserve code needs to be updated to use PGalias. So that is what this is for. I see no reason that a csv file should not be allowed in any case. An author may want to provide a static csv data file with a problem. The copy of the `findMacroFile` that was in PGalias.pm has been deleted. The PG.pl `findMacroFile` calls the method in PGloadfiles.pm instead. Note that the copy in PGalias.pm was not entirely functional to begin with. Also note that the version in PG.pl is only called by the deprecated answerDiscussion.pl macro. The only other places where this method is called is by PGloadfiles.pm internally (for actually loading macro files). The `findAppletCodebase` stub in PGalias.pm was also deleted. The only place that is called is by the `findAppletCodebase` method in PG.pl. So that method is now the stub directly.
The existing `convert_file_to_png_for_tex` already works for that.
d592110 to
09f0627
Compare
|
Merging this now, and the corresponding webwork2 PR. I'm unsure where to make note of the inkscape issue so that it doesn't get lost. |
|
I made a note in the release notes already. It is not complete as to what needs to be done on systems other than Ubuntu though. |

Rewrite the PGalias.pm and PGresource.pm files so that the implemenation makes much more sense and doesn't have the massive kludge that they were.
The behavior is the same as it was. The structure of the data stored in a PGresource object is different (all of the things that were only used internally by PGalias are no longer there), and a minor change to webwork2 is needed to accommodate for that change.
There is one change of note. This switches PGalias.pm from using the "gif2png" external program to using the "convert" external program to convert gif files to png files. Note that the "gif2png" external program is "/usr/bin/giftopnm" by default. Of course "convert" is imagemagick's convert utility. This works just as well (if not better). Note that an animated gif is converted to the first frame (same as before).
Note that "csv" files are also added to the list of allowed auxiliary resources. At this point this is not used, but the rserve code needs to be updated to use PGalias. So that is what this is for. I see no reason that a csv file should not be allowed in any case. An author may want to provide a static csv data file with a problem.
The copy of the
findMacroFilethat was in PGalias.pm has been deleted. The PG.plfindMacroFilecalls the method in PGloadfiles.pm instead. Note that the copy in PGalias.pm was not entirely functional to begin with. Also note that the version in PG.pl is only called by the deprecated answerDiscussion.pl macro. The only other places where this method is called is by PGloadfiles.pm internally (for actually loading macro files).The
findAppletCodebasestub in PGalias.pm was also deleted. The only place that is called is by thefindAppletCodebasemethod in PG.pl. So that method is now the stub directly.