Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ppmsave() creates unexpected output file formats #3377

Open
@ewelot

Description

@ewelot

The function ppmsave() can be used together with a format option to explicitely specify the output file format. Setting this to either ppm, pgm,pbm or pnm one would expect to get an image file containing integer data but unfortunately all variants of the format option are producing PFM files if the vips image data format is float.

While the PFM file format would be useful to preserve data precision it is very uncommon (actually an extendion to the Netpbm formats) and not much supported by other tools (even GNU find does not recognize it). I believe it would be favourable to store integer image data in PPM,PGM,PBM,PNM files. The output file format should therefore be decided on the output file extension or format option (if any other extension is used) and not deduced from the vips image data format. In turn, PFM files should only be created if using the pfm extension or corresponding format option.

When implicit casting to integer formats is required one has to consider the number of bits per pixel (per band) as well. It might therefore be useful to extend the meaning of the bitdepth option and allow values 8 and 16 as well and use this for data range clipping.

Best regards,
Thomas

EDIT: Forgot to mention that I am working with libvips 8.14.1. The format option has been introduced in 8.12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions