[TH] Image Optimizer [Deleted]

I'm on 100,000 of around 500,000 attachments that have been optimized via cmd.php -- The process seems to have slowed down and internal_data/temp has grown quite a bit, about 60G.

Is there a way to stop this process and restart at a certain number? I don't want to stop it now, lest I have to start over from scratch. But if I can tell it to continue from attachment X, then that would be ideal.

This is about 12 hours into the process by the way.
 
Last edited:
Wanted to post an update about this mod for other people interested in how it works on large datasets...

It creates temporary files in the internal_data/temp folder -- and if your attachments directory is say, 37 GB, it will create about 100 GB in the temp folder while it runs. It does not remove the temporary files as it works, instead it only removes them when the entire process is finished.

Make sure you have plenty of extra room when you run this.... if you stop the process it can't restart where you left off and if you stop the process early, I'm not sure if it will even remove the files in the temp dir or you'll have to do it manually.

The size reduction is quite good once the final process is complete. Doing just png and jpeg files my attachment dir went from 37 GB down to 18GB.
 
I got this error on console

1625349453496.webp

Seems I got an older version of gifscile?
Latest version from centos7.
 
What does gifsicle --version output?

LCDF Gifsicle 1.91

Copyright (C) 1997-2018 Eddie Kohler
This is free software; see the source for copying conditions.
There is NO warranty, not even for merchantability or fitness for a
particular purpose.
 
LCDF Gifsicle 1.91

Copyright (C) 1997-2018 Eddie Kohler
This is free software; see the source for copying conditions.
There is NO warranty, not even for merchantability or fitness for a
particular purpose.
According to the GitHub history, it was added in 1.92.
 
Another error i found also, seems webp isn't excluded?

  • ErrorException: Unable to find a suitable image optimizer provider for status ID 5357. Note: This is most likely not a bug and this message is only generated to notify you of the issue. Details: File size: 15742, Mime type: image/webp
  • src/XF/Error.php:75
 
According to the GitHub history, it was added in 1.92.
Is this enough to temporarily patch my issue?
PHP:
#from
$command = $options['binary_path'] . ' --lossy=' . $options['lossy'] . ' --output ' . $newPath . ' --optimize -' . $options['optimize'] . ' -i < ' . $imagePath . ' > ' . $newPath;
#to       
$command = $options['binary_path'] . ' --output ' . $newPath . ' --optimize -' . $options['optimize'] . ' -i < ' . $imagePath . ' > ' . $newPath;
 
Yes, removing the lossy flag from the command will be fine.

If you have a lot of webp images, you may need to use a different optimizer provider.
 
  • Like
Reactions: rdn
What is the correct argument to declare on CLI to use a custom value for "Items to process per page"?

In addition to:
Bash:
php cmd.php xf-rebuild:thimageopt-optimize-existing-image
php cmd.php xf-rebuild:thimageopt-optimize-existing-image --type=attachment
 
The argument is --batch=X or -b X. You can always get a list of available arguments and parameters by typing --help behind a given command.
 
  • Love
Reactions: rdn
I've run the CLI command 2 days ago... after running it for 39 hours and done 42% only of the total attachment I cancel it to change the batch count.

Now running again for 11 hours, seems to skip old attachments that are already optimize.

Problem is /internal_data/temp/ has 285 GB already.

Can I clear this folder now?
Or i should wait for it to finish?
Estimate 2-3 days more to go.

And I have 261 GB free disk only now.
My total forum size before running the command is only 313 GB (2 days ago).
 
Last edited:
Top Bottom