dpc10ster / RJafroc

Artificial Intelligence: Evaluating AI, optimizing AI
19 stars 8 forks source link

Optimise encoding of vignette/image files #14

Closed pwep closed 5 years ago

pwep commented 5 years ago
codecov[bot] commented 5 years ago

Codecov Report

Merging #14 into development will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           development     #14   +/-   ##
===========================================
  Coverage         79.4%   79.4%           
===========================================
  Files               56      56           
  Lines             7309    7309           
===========================================
  Hits              5804    5804           
  Misses            1505    1505

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8c0602f...1c7b645. Read the comment docs.

dpc10ster commented 5 years ago

I have merged your change. Your fix works! No errors no warning and no notes! Not sure exactly how/where you implement pngcrush. I did not have to run any separate command line item. Anyway, this solves the short term problem and we can defer the long term issue until later. I am going to mark this issue as done.

pwep commented 5 years ago

For future reference, pngcrush is available at https://pmt.sourceforge.io/pngcrush/

If you have Homebrew installed on a Mac, you an run brew install pngcrush

For a Debian-based Linux use sudo apt install pngcrush

dpc10ster commented 5 years ago

Thanks!

On Jun 23, 2019, at 13:04, Peter Phillips notifications@github.com wrote:

For future reference, pngcrush is available at https://pmt.sourceforge.io/pngcrush/ https://pmt.sourceforge.io/pngcrush/ If you have Homebrew https://brew.sh/ installed on a Mac, you an run brew install pngcrush

For a Debian-based Linux use sudo apt install pngcrush

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRADUW3RC7VW5JLELVDP36UKVA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLCZQQ#issuecomment-504769730, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRGLSQOEPCBKNJIRGX3P36UKVANCNFSM4H2YMGBQ.

dpc10ster commented 5 years ago

I am installing it right now.

Silly question: why did the NOTE disappear even before I installed it?

On Sun, Jun 23, 2019 at 2:18 PM Dev Chakraborty dpc10ster@gmail.com wrote:

Thanks!

On Jun 23, 2019, at 13:04, Peter Phillips notifications@github.com wrote:

For future reference, pngcrush is available at https://pmt.sourceforge.io/pngcrush/

If you have Homebrew https://brew.sh/ installed on a Mac, you an run brew install pngcrush

For a Debian-based Linux use sudo apt install pngcrush

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRADUW3RC7VW5JLELVDP36UKVA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLCZQQ#issuecomment-504769730, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRGLSQOEPCBKNJIRGX3P36UKVANCNFSM4H2YMGBQ .

pwep commented 5 years ago

Did it disappear before you applied the pull request? The pull request just contained the optimised images - that should have been enough to bring the directory size down can satisfy the check. pngcrush is a separate program from R. We can only use it on existing image files, such as the excel screenshots in vignettes/images. Do use the program if you remake any images in the future (or indeed any .png images for the web.) I had not used the tool before, and I was impressed by the saving it made.

File Original size Optimised size
FROC-TP-Truth-1.png 84K 60K
FROC-TP-Truth-2.png 100K 68K
FROC-TP-Truth-3.png 112K 76K
FROC-TP-Truth-4.png 104K 72K
FROC-TP-Truth-5.png 100K 68K
ROI-FP-1.png 72K 48K
ROI-FP-2.png 72K 48K
ROI-TP-1.png 72K 48K
ROI-Truth-1.png 64K 44K
ROI-Truth-2.png 72K 48K
dpc10ster commented 5 years ago

On Jun 23, 2019, at 15:48, Peter Phillips notifications@github.com wrote:

Did it disappear before you applied the pull request? The pull request just contained the optimised images - that should have been enough to bring the directory size down can satisfy the check. pngcrush is a separate program from R. We can only use it on existing image files, such as the excel screenshots in vignettes/images. Do use the program if you remake any images in the future (or indeed any .png images for the web.) I had not used the tool before, and I was impressed by the saving it made. File Original size Optimised size FROC-TP-Truth-1.png 84K 60K FROC-TP-Truth-2.png 100K 68K FROC-TP-Truth-3.png 112K 76K FROC-TP-Truth-4.png 104K 72K FROC-TP-Truth-5.png 100K 68K ROI-FP-1.png 72K 48K ROI-FP-2.png 72K 48K ROI-TP-1.png 72K 48K ROI-Truth-1.png 64K 44K ROI-Truth-2.png 72K 48K

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRASF52JDUW5XCNG2O3P37HQVA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLFUXQ#issuecomment-504781406, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRGI7KKCHFFGHWUKJVLP37HQVANCNFSM4H2YMGBQ .

dpc10ster commented 5 years ago

I think I get it now; need to use the command line to compress the files; dev

On Sun, Jun 23, 2019 at 4:03 PM Dev Chakraborty dpc10ster@gmail.com wrote:

  • It disappeared after I applied the pull request. That explains why the note disappeared.

  • I see that pngcrush is not a CRAN package. I have installed it via the brew command you set me, but I don't know how to apply it.

  • The file size reductions are impressive

On Jun 23, 2019, at 15:48, Peter Phillips notifications@github.com wrote:

Did it disappear before you applied the pull request? The pull request just contained the optimised images - that should have been enough to bring the directory size down can satisfy the check. pngcrush is a separate program from R. We can only use it on existing image files, such as the excel screenshots in vignettes/images. Do use the program if you remake any images in the future (or indeed any .png images for the web.) I had not used the tool before, and I was impressed by the saving it made. File Original size Optimised size FROC-TP-Truth-1.png 84K 60K FROC-TP-Truth-2.png 100K 68K FROC-TP-Truth-3.png 112K 76K FROC-TP-Truth-4.png 104K 72K FROC-TP-Truth-5.png 100K 68K ROI-FP-1.png 72K 48K ROI-FP-2.png 72K 48K ROI-TP-1.png 72K 48K ROI-Truth-1.png 64K 44K ROI-Truth-2.png 72K 48K

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRASF52JDUW5XCNG2O3P37HQVA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLFUXQ#issuecomment-504781406, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRGI7KKCHFFGHWUKJVLP37HQVANCNFSM4H2YMGBQ .

pwep commented 5 years ago

Using the pngcrush command line is very easy.

pngcrush infile.png outfile.png

I ran it with the -brute flag to get the tool to try all 114 different compression methods(!) and use the one with the smallest filesize.

dpc10ster commented 5 years ago

How do I restrict the script to a specified directory?

On Sun, Jun 23, 2019 at 5:05 PM Peter Phillips notifications@github.com wrote:

Using the pngcrush command line is very easy.

pngcrush infile.png outfile.png

I ran it with the -brute flag to get the tool to try all 114 different compression methods(!) and use the one with the smallest filesize.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRGBWF2E27GRBHRIUFTP37QTFA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLHBCQ#issuecomment-504787082, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRCGRATES6Q54WFS4YLP37QTFANCNFSM4H2YMGBQ .

dpc10ster commented 5 years ago

As you can see, I am also ignorant in Unix :)

On Sun, Jun 23, 2019 at 6:01 PM Dev Chakraborty dpc10ster@gmail.com wrote:

  • I wish I saw this earlier :( I used an online script that compressed all png files on my iMac computer I had to undo it by searching for all files ending in pngcrushed and deleting them.

How do I restrict the script to a specified directory?

On Sun, Jun 23, 2019 at 5:05 PM Peter Phillips notifications@github.com wrote:

Using the pngcrush command line is very easy.

pngcrush infile.png outfile.png

I ran it with the -brute flag to get the tool to try all 114 different compression methods(!) and use the one with the smallest filesize.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRGBWF2E27GRBHRIUFTP37QTFA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLHBCQ#issuecomment-504787082, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRCGRATES6Q54WFS4YLP37QTFANCNFSM4H2YMGBQ .

pwep commented 5 years ago

How do I restrict the script to a specified directory?

Assuming you are on the Mac and can bring up the Terminal window. In a Terminal window, change to the directory containing the images you want to crush.

cd path/to/my/images_folder

To crush each .png file in the directory and create a new image with -crushed.png appended to the filename...

pngcrush -e -crushed.png *.png

Alternatively, change directory to the directory containing your image folder, and make a new crushed-images directory as an output destination:

cd path/to/my
mkdir crushed-images

Run pngcrush specifying the path to the input images, and the directory to hold the output images (the one we just created).

pngcrush -d crushed-images images_folder/*.png

This way does not append anything to the filename, but creates a crushed version in the specified output directory.

For more options and flags, run pngcrush --help You only have to run this programme once, to optimise the encoding in your .png file.

dpc10ster commented 5 years ago

Peter, Thank you very much. I have used Terminal many times but I confess that I am usually just copying and pasting scripts. I think I can handle it now. Dev

On Mon, Jun 24, 2019 at 12:10 PM Peter Phillips notifications@github.com wrote:

How do I restrict the script to a specified directory?

Assuming you are on the Mac and can bring up the Terminal window. In a Terminal window, change to the directory containing the images you want to crush.

cd path/to/my/images_folder

To crush each .png file in the directory and create a new image with -crushed.png appended to the filename...

pngcrush -e -crushed.png *.png

Alternatively, change directory to the directory containing your image folder, and make a new crushed-images directory as an output destination:

cd path/to/my mkdir crushed-images

Run pngcrush specifying the path to the input images, and the directory to hold the output images (the one we just created).

pngcrush -d crushed-images images_folder/*.png

This way does not append anything to the filename, but creates a crushed version in the specified output directory.

For more options and flags, run pngcrush --help You only have to run this programme once, to optimise the encoding in your .png file.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dpc10ster/RJafroc/pull/14?email_source=notifications&email_token=AH4NJRCCJXYZQHOVXP42UVLP4DWXZA5CNFSM4H2YMGB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYNNXLA#issuecomment-505076652, or mute the thread https://github.com/notifications/unsubscribe-auth/AH4NJRFIUCCIURWOEWNXNWTP4DWXZANCNFSM4H2YMGBQ .