octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #10316] Add Resolution and ResolutionUnit


From: anonymous
Subject: [Octave-patch-tracker] [patch #10316] Add Resolution and ResolutionUnit parameters to imwrite.
Date: Fri, 17 Feb 2023 23:37:04 -0500 (EST)

URL:
  <https://savannah.gnu.org/patch/?10316>

                 Summary: Add Resolution and ResolutionUnit parameters to
imwrite.
                 Project: GNU Octave
               Submitter: None
               Submitted: Sat 18 Feb 2023 04:37:02 AM UTC
                Category: Core : new feature
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Sat 18 Feb 2023 04:37:02 AM UTC By: Anonymous
To clarify, this patch is all about setting the DPI/resolution typically
stored in the image's EXIF tags and measured in, e.g. pixels per inch -- as
opposed to the more common meaning of "resolution" as measured in pixels. 

For context, the follow are how DPI/resolution can be set on TIFF and PNG
images in MATLAB (MATLAB does not support setting resolution for any other
formats):


imwrite(img, "tiff.tif", "Resolution",  300);  % Generates a 300
pixels-per-inch TIFF file.
imwrite(img, "png.png",  "XResolution", 300, "ResolutionUnit", "meter");    %
Generates a 300 pixels-per-meter PNG file.
imwrite(img, "png.png",  "XResolution", 300, "ResolutionUnit", "unknown");  %
Generates a 300 pixels-per-<unknown> PNG file.
imwrite(img, "png.png",  "XResolution", 300);  % Generates a 300
pixels-per-<unknown> PNG file.


Given that Octave's philosophy appears to be to *not* copy MATLAB's
inconsistencies, I propose that Octave's resolution setting should be as
follows:


% filename = *.tif, *.png, *.jpg, *.bmp.
imwrite(img, filename, "Resolution", 300);                                 %
Generates a 300 pixels-per-inch image file.
imwrite(img, filename, "Resolution", 300, "ResolutionUnit", "inch");       %
Generates a 300 pixels-per-inch image file.
imwrite(img, filename, "Resolution", 300, "ResolutionUnit", "centimeter"); %
Generates a 300 pixels-per-cm image file.
imwrite(img, filename, "Resolution", 300, "ResolutionUnit", "meter");      %
Generates a 300 pixels-per-meter image file.
imwrite(img, filename, "Resolution", [300 600], "ResolutionUnit", "inch"); %
Generates a non-unity PAR - 300 ppi x 600 ppi.


This will work perfectly with existing MATLAB code that writes TIFFs, but will
be incompatible with existing MATLAB code that writes PNGs. In my opinion this
is a worthwhile tradeoff, as the code to simultaneously support Resolution,
XResolution nad YResolution tags (and have a different default resolution unit
depending on the file format) is complex, and the resulting documentation ends
up super repetitive and confusing.

I've attached a diff that implements my proposal above, happy to implement any
suggestions in code review.







    _______________________________________________________
File Attachments:


-------------------------------------------------------
Date: Sat 18 Feb 2023 04:37:02 AM UTC  Name: imwrite_resolution.diff  Size:
6KiB   By: None

<http://savannah.gnu.org/patch/download.php?file_id=54375>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/patch/?10316>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]