bugGNU Octave - Bugs: bug #62974, The `isa` function returned by...

 
 

bug #62974: The `isa` function returned by imformats doesn't work

Submitter:  Maged Rifaat <magedrifaat>
Submitted:  Sun 28 Aug 2022 08:17:45 PM UTC
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 7.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Wed 31 Aug 2022 01:50:15 PM UTC, comment #4: 

Thanks for testing. Closing as fixed.

Markus M├╝tzel <mmuetzel>
Project Member
Wed 31 Aug 2022 01:31:39 PM UTC, comment #3: 

I could reproduce the behavior from comment #0 on my laptop (Octave 7.2.0, linux). Even when I have a file "example.png" in the working directory, the first demo code in comment #0 returns me the value tf=0.

After recompiling Octave from the repository (stable branch, Octave 7.2.1), directly after the patch from comment #2, and also having the png-file in the working directory, the same demo code in comment #0 now returns the proper value of tf=1.

So I can confirm, that the patch from comment #2 fixes this issue. Thanks for your quick response, Rik.

Hartmut <hardy>
Tue 30 Aug 2022 10:56:23 PM UTC, comment #2: 

The diagnosis seems correct, that is, there is a typo in imformat.m.  I made the fix here http://hg.savannah.gnu.org/hgweb/octave/rev/a33a9c87220b.

Marking as Ready for Test.

Rik <rik5>
Project Administrator
Sun 28 Aug 2022 09:49:10 PM UTC, comment #1: 

Thanks for noting this. I just added the image package maintainers in cc.

Hartmut <hardy>
Sun 28 Aug 2022 08:17:45 PM UTC, original submission:  

The imformats function returns a struct with function handles to handle a specific format. One of them is a field `isa` which should be a function handle that returns true if supplied with a file name that represents an image of the given format.

For example:

png_format = imformats("png");
ispng = png_format.isa;
tf = ispng ("example.png")

In this case, tf should be a logical 1 but it isn't.

The problem seems to be a typo in the function isa_magick in imformats.m:

function bool = isa_magick (coder, filename)
  bool = false;
  try
    info = __magick_ping__ (filename, 1);
    bool = strcmp (coder, info.Format);
  end_try_catch
endfunction

The code attempts to use info.Format with a capital F in `Format`, while the internal `__magick_ping__` function returns a struct with lower case `format`.

Maged Rifaat <magedrifaat>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53614:  fix_isa.patch added by magedrifaat (690B - text/x-patch - A patch to fix the typo)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by magedrifaat (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-31 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2022-08-30 rik5 StatusNone Ready For Test
    2022-08-28 magedrifaat Attached File- Added fix_isa.patch, #53614

    Back to the top


    Powered by Savane 3.9