Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix calling pnmcrop with a duplicated -sides option (aka PNMCROPOPT) #73

Merged
merged 1 commit into from Nov 11, 2021
Merged

Conversation

mehw
Copy link
Contributor

@mehw mehw commented Nov 10, 2021

If the variable PNMCROPOPT is defined as -sides via config/config.pl in pstoimg.bin, calling

pnmcrop -bot -sides $PNMCROPOPT

will give an error, due to the duplicated option.

This probably relates to issues #40 and #41.

If the variable PNMCROPOPT is defined as "-sides" via config/config.pl
in pstoimg.bin, calling `pnmcrop -bot -sides $PNMCROPOPT` will give an
error, due to the duplicated option.
@@ -1300,9 +1300,9 @@ sub crop_scale_etc {
my $edge = $1;
my $croparg = '';
if($edge =~ /b/i) {
$croparg = "-bot -sides $PNMCROPOPT ";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PNMCROPOPT may be set only to -sides via config/config.pl.

@danielgildea
Copy link
Contributor

Can you provide a test case?
How are you invoking latex2html or pstoimg?
What version of pnmcrop are you using?

@mehw
Copy link
Contributor Author

mehw commented Nov 10, 2021

pnmcrop version

pnmcrop -version
pnmcrop: Using libnetpbm from Netpbm Version: Netpbm 10.86.24
pnmcrop: Built at 2021-11-07 20:44:53
pnmcrop: Built by portage
pnmcrop: BSD defined
pnmcrop: RGB_ENV='RGBDEF'
pnmcrop: RGBENV= 'RGBDEF' (env vbl is unset)

Test case (invocation of latex2html/pstoimg)

To trigger the bug you may try with the following:

mkdir test
cd test
curl https://arxiv.org/e-print/1706.03762 -o 1706.03762.tar
tar -xf 1706.03762.tar
latex2html -nouse_dvipng -image_type gif model_architecture.tex
...
Transforming PDF images to postscript using gs/ps2write ...
PDFCROP 1.40, 2020/06/06 - Copyright (c) 2002-2020 by Heiko Oberdiek, Oberdiek Package Support Group.
==> 41 pages written on `./images-crop.pdf'.
Converting image #25
Converting image #36
Converting image #16
pstoimg.pl: Error: "/usr/bin/pnmcrop < /tmp/l2h3902/p3941.pnm | /usr/bin/pnmcrop -bot -sides  -sides  | /usr/bin/pnmcrop -l -sides  -sides   > /tmp/l2h3902/p3941.t00" failed: Illegal seek

Error while converting image

Error: Cannot read 'img16.gif': No such file or directory
...

pnmcrop doesn't like a duplicated option, i.e. -sides -sides (where the last -sides is $PNMCROPOPT).

@danielgildea
Copy link
Contributor

Thanks. Your test case works ok for me, even though it does use a duplicate "-sides" in processing image 16. I can also run "pnmcrop -sides -sides" from the command line with no problem.

In your test case, I do get an error on image # 23, because page 23 of images.pdf is blank. This is because \dmodel is undefined in the input file (which is not the main latex file of the document).

Do you get an image of an eqn on page 16 of images.pdf?

What happens when you run "pnmcrop -sides -sides" from the command line?

@mehw
Copy link
Contributor Author

mehw commented Nov 11, 2021

Thanks for the prompt reply.

Thanks. Your test case works ok for me, even though it does use a duplicate "-sides" in processing image 16. I can also run "pnmcrop -sides -sides" from the command line with no problem.

On my machine it's different... pnmcrop refuses to accept a duplicated option (see more at the bottom).

latex2html -nouse_dvipng -image_type gif model_architecture.tex
...
Converting image #16
pstoimg.pl: Error: "/usr/bin/pnmcrop < /tmp/l2h18162/p18203.pnm | /usr/bin/pnmcrop -bot -sides  -sides  | /usr/bin/pnmcrop -l -sides  -sides   > /tmp/l2h18162/p18203.t00" failed: Illegal seek

Error while converting image

Error: Cannot read 'img16.gif': No such file or directory
...

In your test case, I do get an error on image # 23, because page 23 of images.pdf is blank. This is because \dmodel is undefined in the input file (which is not the main latex file of the document).

It's the same for me. I took the first latex example at hand... I think it's normal, the problem is the duplicated -sides option (see more at the bottom).

Do you get an image of an eqn on page 16 of images.pdf?

Yes I do, it's something like the below representation:

                              QK^T
Attention(Q,K,V) = softmax(----------)V
                            sqrt(dk)

What happens when you run "pnmcrop -sides -sides" from the command line?

pnmcrop -bot -sides -sides p20072.pnm
pnmcrop: You cannot specify more than one of -black, -white, -sides, -bg-color, -bg-corner

@danielgildea danielgildea merged commit a95d4d5 into latex2html:master Nov 11, 2021
@mehw
Copy link
Contributor Author

mehw commented Nov 11, 2021

Thanks for merging ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants