JacobDev1 / xl-converter

Easy-to-use image converter for modern formats. Supports multithreading, drag 'n drop, and downscaling.
https://codepoems.eu/xl-converter
Other
118 stars 4 forks source link

Support of TIFF file Format #23

Closed Spalar closed 2 months ago

Spalar commented 3 months ago

Hi Jacob, Thanks for a great software and easy to use ! I understand that addition of new format can be tedious. As you suggested in your code, I tried to add Tiff with Image Magick. I was able to convert tiff files but with some caveats.

  1. Size of final JPEG only reduced to a certain extent.

image image

Properties of Image after Double Conversion.

image image

Images Comparing Details of Original TIFF and JPEG Converted with Final Image Size

  1. Auto Choosing the Encoder, I had to choose Image Magick as encoder manually as I knew it supported (Other one Failed). When Tiff Image is used, automatic change to Image Magick will require some modifications.
Version | 0.9.9 |   -- | -- | -- OS | Windows |     |   |   Output |   |   format | JPG |   quality | 100 |   lossless | False |   lossless_if_smaller | False |   max_compression | False |   effort | 7 |   intelligent_effort | False |   reconstruct_jpg | True |   jxl_mode | Default |   jpg_encoder | JPEGLI from JPEG XL |   if_file_exists | Rename |   custom_output_dir | True |   keep_dir_struct | False |   delete_original | False |   delete_original_mode | To Trash |   smallest_format_pool | [('png', True), ('webp', True), ('jxl', True)] |     |   |   Downscaling |   |   enabled | True |   mode | File Size |   percent | 80 |   width | 2000 |   height | 2000 |   file_size | 9700 |   shortest_side | 1080 |   longest_side | 1920 |   resample | Default |     |   |   Misc. |   |   keep_metadata | Encoder - Wipe |   attributes | False |     |   |   Exceptions |   |   ID | Exception | Extension P2 | Conversion failed, output not found. | .tif

Try to add this when you have time !

JacobDev1 commented 3 months ago

Hello,

Full TIFF support would require a redesign of the core components. TIFF can contain layers. Cramming all of them into another format might not be possible.

This is beyond the scope of this program. There are too many edge cases to deal with.

JacobDev1 commented 3 months ago

Let me explain further.

I can merge all layers into one with ImageMagick by adding -background none -layers merge while converting TIFF to PNG. From there I can encode it to either AVIF or JPEG XL. Unfortunately, if there is an embedded thumbnail, a black rectangle will appear in the top-left corner.

GIMP saves TIFFs with a thumbnail by default...

I'm certain there will be many more similar issues to account for. The ImageMagick on my Linux cannot even open TIFFs - convert-im6.q16: Deprecated and troublesome old-style JPEG compression mode.

I'd prefer to focus on other features. For processing TIFFs use XnConvert instead. It handles all those edge cases rather well. You can even use it to generate PNGs, which my program will accept.

Spalar commented 2 months ago

Thanks for the suggestions ! All these points will help to sort out other edge cases for me. I'll work in the same direction, will try XnConvert.

Update: I like the Size Control of File in XL-Converter which is my basic requirement. XnConvert looks too complicated for Tiff to Jpeg task I specifically need. Will use your code and build on to have the features I need :)

JacobDev1 commented 2 months ago

XL Converter 1.0 will feature partial TIFF support.

This support will not include multi-page images and those with additional data (like thumbnails).

Some TIFFs relying on older technologies will fail to decode. In that case, fall back to using XnConvert.