Conversation
|
@Swader Could you take a look at this and let me know what you think? Most of the pictures definitely get smaller, but there are some that actually got bigger in filesize (not sure why that's happening). Clone this branch locally and run |
|
The file size increase can happen if the image was pre-optimized in a good tool before, like Photoshop or Illustrator. This does a very good job so any "compression" is actually inflation. It's a case by case thing I suppose, and JPG cannot be optimized with a PNG optimizer tool, or vice versa, so it should be a tool per file type. The arguments are def up for tweaking, yeah. Will check specific output and see what can be done, thanks for getting this rolling. |
|
The question to take this PR forward is what quality of images we will be happy with, then we can set the image optimizer settings appropriately and replace all the images in the Before (257.7 KiB)After Optimization w/ Resizing (82.3 KiB)After Optimization w/o Resizing (143.3 KiB)So based on this one example we get approximately a size reduction of 44% from just optimization while optimization and resizing gives us 68% gain from the original with a noticeable loss of quality. My preference would be to just do the optimization on the images without resizing. |
|
Agreed, bigger images also lend themselves well to the PDF export |
|
I get a bunch of nulls as output as the script works and a zlib error when testing: |
|
Some more verbose errors: Debugging... |
|
Ok, heavy modifications are needed:
for (const path of images) {
let ext = path.split(".").pop();
sharp(path)
...
.toFile(path + ".r." + ext, (err) => {
...
}
await Promise.all(
images
.map((img) => { let ext = path.split(".").pop(); img + ".r." + ext })
....
);
};
That last point would be the only optimization that would really help us achieve results. In my tests, all my PNGs saved from screenshots of Windows' snap tool are optimized to the bone. In fact, see here: The files that end with |
|
Is this still being worked on? |
|
@lsaether what's up with this? Is it too much work to make it securely up to date with master at this point? |




closes #911
This PR does two things: