croptool icon indicating copy to clipboard operation
croptool copied to clipboard

Choosing lossless mode would still crop in precise mode

Open royjor2016 opened this issue 3 years ago • 6 comments

i think, that it's been a while, that lossless mode has disappeared. choosing lossless is now actually the same as choosing precise.

my observations:

  1. in the past, when previewing a crop of jpg in lossless, the dimension would often be augmented above and on the left, because jpgs are handled in 8x8 or 16x16 pixel blocks. now no matter how you wanna crop a jpg, the specified dimension would always be allowed, which could only be true in precise mode.
  2. cropping files in https://commons.wikimedia.org/wiki/Category:Incomplete_files_(5_MB_interruption) in lossless mode used to end up in errors, but now it's possible, and resultant filesize is the same as a precise crop, e.g. https://commons.wikimedia.org/wiki/File:Dairy_Heifers_on_Pasture_.jpg .

royjor2016 avatar Jan 12 '22 11:01 royjor2016

@danmichaelo Could this have been introduced by the refactor in September 2020? There's likely a large number of files on commons that are being silently damaged by this bug.

zanhecht avatar Jun 15 '22 15:06 zanhecht

@danmichaelo Looking into the code more, it seems like the September 2020 refactor fundamentally broke things. The various types of crop were broken out into subclasses (for example, lossless Jpeg cropping was broken out into JpegFile and Gif cropping to GifFile), but as far as I can tell the only subclasses that are actually being called out by the program in FileRepository.php are TiffFile, DjvuFile, PdfFile, and SvgFile, all of which return errors instead of actually working. All other file types are being handled by the generic imagemagick call in File.php.

This is why lossless crops are no longer lossless, Gif files say they are being cropped with precise or lossless mode instead of "gif mode", and TIFFs, PDFs, and DJVUs no longer work.

If these issues aren't easy to resolve, perhaps to the tool should be rolled back to 1.4 (before the refactoring).

zanhecht avatar Jun 17 '22 14:06 zanhecht

~~Duplicate of #163~~

Jonteemil avatar Jun 29 '22 15:06 Jonteemil

Duplicate of #163

There may be a similar root cause, but it's not a duplicate. #163 is about GIFs and PNGs saying that impossible crop modes were used, this bug is about the fact that there is no way to actually do a lossless crop, and that no matter which mode CropTool says its using in the logs and edit comments, it's actually just passing the files to imagemagick to do a regular lossy crop.

zanhecht avatar Jun 29 '22 15:06 zanhecht

Okay, that makes sense.

Jonteemil avatar Jun 29 '22 15:06 Jonteemil

Should be closed now #182 has been merged

geofferb avatar Mar 28 '24 07:03 geofferb