fabianmichael/kirby-imagekit

source images get deleted

bnomei opened this issue · 5 comments

using most current imagekit and imageset.

if have a couple of imageoptim optimized files. but i also have jpg optimizers setup in config file.
the result is since my source files are smaller than on server optimized the source files get deleted!

why is that?

protected function keepSmallestFile($target, $alternative) {

By source files, do you means the originals inside of the content folder?

What optimizers are activated in you config file?

Regarding the linked piece of code: When testing optimizers, I realised that sometimes the resulting »optimized« version of a file is bigger than the input file. Some optimizers can handle that and only override a file, when the optimization was able to reduce file size. But some don’t offer this ability, so I decided to check this in PHP.

yes. it deletes one JPG image file out of the content folder for each time i try to call imagekits widget. it seems to crash after the first image once the original (content folder file) gets removed (which it should not ever).

c::set('imagekit.optimize', true);
c::set('imagekit.gifsicle.bin', 'PATH/gifsicle-linux');
c::set('imagekit.jpegtran.bin', 'PATH/jpegtran-linux');
c::set('imagekit.optipng.bin',  'PATH/optipng-linux');
c::set('imagekit.pngquant.bin', 'PATH/pngquant-linux');

it seems it has nothing to do with optimizers after all. if the colorthief lib gets caught in a execution timeout the file process gets removed. yes, thats imageset actually not imagekit – i know.

c::set('imageset.placeholder', 'color');

Error on
plugins/imageset/vendors/ColorThief/Image/Adapter/ImagickImageAdapter.php on line: 85

Okay, I had a more in-depth look at the code and added an additional check before calling ColorThief.

I’ve created a new branch for that in the ImageSet repo, please check if it now works for you, because I could not replicate your error: https://github.com/fabianmichael/kirby-imageset/tree/source-images-deleted-error

Thanks for your help!

I could not replicate my error it with this new tree. Thanks!