annotate scripts/image/imformats.m @ 27918:b442ec6dda5c

use centralized file for copyright info for individual contributors * COPYRIGHT.md: New file. * In most other files, use "Copyright (C) YYYY-YYYY The Octave Project Developers" instead of tracking individual names in separate source files. The motivation is to reduce the effort required to update the notices each year. Until now, the Octave source files contained copyright notices that list individual contributors. I adopted these file-scope copyright notices because that is what everyone was doing 30 years ago in the days before distributed version control systems. But now, with many contributors and modern version control systems, having these file-scope copyright notices causes trouble when we update copyright years or refactor code. Over time, the file-scope copyright notices may become outdated as new contributions are made or code is moved from one file to another. Sometimes people contribute significant patches but do not add a line claiming copyright. Other times, people add a copyright notice for their contribution but then a later refactoring moves part or all of their contribution to another file and the notice is not moved with the code. As a practical matter, moving such notices is difficult -- determining what parts are due to a particular contributor requires a time-consuming search through the project history. Even managing the yearly update of copyright years is problematic. We have some contributors who are no longer living. Should we update the copyright dates for their contributions when we release new versions? Probably not, but we do still want to claim copyright for the project as a whole. To minimize the difficulty of maintaining the copyright notices, I would like to change Octave's sources to use what is described here: https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html in the section "Maintaining centralized copyright notices": The centralized notice approach consolidates all copyright notices in a single location, usually a top-level file. This file should contain all of the copyright notices provided project contributors, unless the contribution was clearly insignificant. It may also credit -- without a copyright notice -- anyone who helped with the project but did not contribute code or other copyrighted material. This approach captures less information about contributions within individual files, recognizing that the DVCS is better equipped to record those details. As we mentioned before, it does have one disadvantage as compared to the file-scope approach: if a single file is separated from the distribution, the recipient won't see the contributors' copyright notices. But this can be easily remedied by including a single copyright notice in each file's header, pointing to the top-level file: Copyright YYYY-YYYY The Octave Project Developers See the COPYRIGHT file at the top-level directory of this distribution or at https://octave.org/COPYRIGHT.html. followed by the usual GPL copyright statement. For more background, see the discussion here: https://lists.gnu.org/archive/html/octave-maintainers/2020-01/msg00009.html Most files in the following directories have been skipped intentinally in this changeset: doc libgui/qterminal liboctave/external m4
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 15:38:17 -0500
parents 823b4bcf79fc
children 1891570abac8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27216
diff changeset
1 ## Copyright (C) 2013-2019 The Octave Project Developers
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27216
diff changeset
2 ##
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27216
diff changeset
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27216
diff changeset
4 ## or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27216
diff changeset
5 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
6 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
7 ## This file is part of Octave.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
8 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24458
diff changeset
9 ## Octave is free software: you can redistribute it and/or modify it
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
10 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24458
diff changeset
11 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## (at your option) any later version.
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
13 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
14 ## Octave is distributed in the hope that it will be useful, but
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## GNU General Public License for more details.
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
18 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
19 ## You should have received a copy of the GNU General Public License
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
20 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24458
diff changeset
21 ## <https://www.gnu.org/licenses/>.
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
22
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
23 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
24 ## @deftypefn {} {} imformats ()
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
25 ## @deftypefnx {} {@var{formats} =} imformats (@var{ext})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
26 ## @deftypefnx {} {@var{formats} =} imformats (@var{format})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
27 ## @deftypefnx {} {@var{formats} =} imformats ("add", @var{format})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
28 ## @deftypefnx {} {@var{formats} =} imformats ("remove", @var{ext})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
29 ## @deftypefnx {} {@var{formats} =} imformats ("update", @var{ext}, @var{format})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20176
diff changeset
30 ## @deftypefnx {} {@var{formats} =} imformats ("factory")
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
31 ## Manage supported image formats.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
32 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
33 ## @var{formats} is a structure with information about each supported file
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
34 ## format, or from a specific format @var{ext}, the value displayed on the
25472
9771111f04f4 doc: Use @var rather than @code to mark inputs to functions in docstrings.
Rik <rik@octave.org>
parents: 25054
diff changeset
35 ## field @var{ext}. It contains the following fields:
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
36 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
37 ## @table @asis
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
38 ## @item ext
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
39 ## The name of the file format. This may match the file extension but Octave
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
40 ## will automatically detect the file format.
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
41 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
42 ## @item description
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
43 ## A long description of the file format.
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
44 ##
16922
bfd119642f6a doc: Fix some spellings in image.texi.
Rik <rik@octave.org>
parents: 16916
diff changeset
45 ## @item @nospell{isa}
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
46 ## A function handle to confirm if a file is of the specified format.
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
47 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
48 ## @item write
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
49 ## A function handle to write if a file is of the specified format.
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
50 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
51 ## @item read
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
52 ## A function handle to open files the specified format.
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
53 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
54 ## @item info
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
55 ## A function handle to obtain image information of the specified format.
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
56 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
57 ## @item alpha
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
58 ## Logical value if format supports alpha channel (transparency or matte).
17170
d6499c14021c doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 17086
diff changeset
59 ##
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
60 ## @item multipage
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
61 ## Logical value if format supports multipage (multiple images per file).
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
62 ## @end table
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
63 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
64 ## It is possible to change the way Octave manages file formats with the
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
65 ## options @qcode{"add"}, @qcode{"remove"}, and @qcode{"update"}, and supplying
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
66 ## a structure @var{format} with the required fields. The option
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17170
diff changeset
67 ## @qcode{"factory"} resets the configuration to the default.
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
68 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
69 ## This can be used by Octave packages to extend the image reading capabilities
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
70 ## Octave, through use of the PKG_ADD and PKG_DEL commands.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
71 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
72 ## @seealso{imfinfo, imread, imwrite}
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
73 ## @end deftypefn
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
74
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
75 ## Author: Carnë Draug <carandraug@octave.org>
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
76
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
77 function varargout = imformats (arg1, arg2, arg3)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
78
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
79 if (nargin > 3)
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
80 print_usage ();
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
81 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
82
19653
b95aab49b6be imformats: memory lock function to prevent "registry" of imageIO to be cleared
Carnë Draug <carandraug@octave.org>
parents: 19278
diff changeset
83 mlock (); # prevent formats to be removed by "clear all"
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
84 persistent formats = default_formats ();
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
85
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
86 if (nargin == 0 && nargout == 0)
20170
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
87 pretty_print_formats (formats);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
88 elseif (nargin >= 1)
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
89 if (isstruct (arg1))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
90 arrayfun (@is_valid_format, arg1);
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
91 ## FIXME: what is the return value in this situation?
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
92 formats = arg1;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
93
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
94 elseif (ischar (arg1))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
95 switch (tolower (arg1))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
96 case "add",
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
97 if (! isstruct (arg2))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
98 error ("imformats: FORMAT to %s must be a structure.", arg1);
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
99 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
100 arrayfun (@is_valid_format, arg2);
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
101 formats(end + 1: end + numel (arg2)) = arg2;
16907
04f4f067eb33 imformats: fix typos and silence some statements.
Carnë Draug <carandraug@octave.org>
parents: 16906
diff changeset
102 varargout{1} = formats;
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
103
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
104 case {"remove", "update"},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
105 if (! ischar (arg2))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
106 error ("imformats: EXT to %s must be a string.", arg1);
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
107 endif
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
108 ## FIXME: suppose a format with multiple extensions. If one of
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
109 ## them is requested to be removed, should we remove the
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
110 ## whole format, or just that extension from the format?
16907
04f4f067eb33 imformats: fix typos and silence some statements.
Carnë Draug <carandraug@octave.org>
parents: 16906
diff changeset
111 match = find_ext_idx (formats, arg2);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
112 if (! any (match))
27216
823b4bcf79fc unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
113 error ("imformats: no EXT '%s' found.", arg2);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
114 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
115 if (strcmpi (arg1, "remove"))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
116 formats(match) = [];
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
117 else
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
118 ## then it's update
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
119 if (! isstruct (arg3))
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
120 error ("imformats: FORMAT to update must be a structure.");
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
121 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
122 is_valid_format (arg3);
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
123 formats(match) = arg3;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
124 endif
16907
04f4f067eb33 imformats: fix typos and silence some statements.
Carnë Draug <carandraug@octave.org>
parents: 16906
diff changeset
125 varargout{1} = formats;
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
126
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
127 case "factory",
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
128 formats = default_formats ();
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
129 otherwise
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
130 ## then we look for a format with that extension.
16907
04f4f067eb33 imformats: fix typos and silence some statements.
Carnë Draug <carandraug@octave.org>
parents: 16906
diff changeset
131 match = find_ext_idx (formats, arg1);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
132 ## For matlab compatibility, if we don't find any format we must
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
133 ## return an empty struct with NO fields. We can't use match as mask
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
134 if (any (match))
16907
04f4f067eb33 imformats: fix typos and silence some statements.
Carnë Draug <carandraug@octave.org>
parents: 16906
diff changeset
135 varargout{1} = formats(match);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
136 else
16907
04f4f067eb33 imformats: fix typos and silence some statements.
Carnë Draug <carandraug@octave.org>
parents: 16906
diff changeset
137 varargout{1} = struct ();
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
138 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
139 endswitch
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
140 else
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
141 error ("imformats: first argument must be either a structure or string.");
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
142 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
143 else
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
144 varargout{1} = formats;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
145 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
146
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
147 endfunction
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
148
24458
516437d2194d don't allow function parameters (in or out) to be persistent
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
149 function rformats = default_formats ()
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
150
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
151 ## The available formats are dependent on what the user has installed at
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
152 ## a given time, and how GraphicsMagick was built. Checking for
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
153 ## GraphicsMagick features when building Octave is not enough since it
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
154 ## delegates some of them to external programs which can be removed or
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
155 ## installed at any time.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
156 ## The recommended method would be to use CoderInfoList() to get a list of
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
157 ## all available coders and try to write and read back a small test image.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
158 ## But this will not work since some coders are readable or writable only.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
159 ## It will still fail if we test only the ones marked as readable and
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
160 ## writable because some RW coders are not of image formats (NULL, 8BIM,
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
161 ## or EXIF for example).
27216
823b4bcf79fc unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
162 ## So we'd need a blacklist (unacceptable because a 'bad' coder may be
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
163 ## added later) or a whitelist. A whitelist means that even with a
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
164 ## super-fancy recent build of GraphicsMagick, some formats won't be listed
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
165 ## by imformats but in truth, we will still be able to read and write them
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
166 ## since imread() and imwrite() will give it a try anyway.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
167 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
168 ## For more info and comments from the GraphicsMagick main developer, see
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
169 ## http://sourceforge.net/mailarchive/forum.php?thread_name=alpine.GSO.2.01.1304301916050.2267%40freddy.simplesystems.org&forum_name=graphicsmagick-help
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
170
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
171 persistent formats = struct ( "coder", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
172 "ext", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
173 "isa", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
174 "info", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
175 "read", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
176 "write", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
177 "alpha", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
178 "description", {},
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
179 "multipage", {});
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
180
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
181 ## Image IO abilities won't change during the same Octave session,
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
182 ## there's no need to go and calculate it all over again if we are
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
183 ## requested to reset back to factory.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
184 if (! isempty (formats))
24458
516437d2194d don't allow function parameters (in or out) to be persistent
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
185 rformats = formats;
17312
088d014a7fe2 Use semicolon after "return" statement in core m-files.
Rik <rik@octave.org>
parents: 17281
diff changeset
186 return;
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
187 endif
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
188
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
189 ## Building the formats info
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
190 ##
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
191 ## As mentioned above we start with a whitelist of coders. Since the
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
192 ## GraphicsMagick build may be missing some coders, we will remove those
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
193 ## from the list. Some info can be obtained directly from GraphicsMagick
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
194 ## through the CoderInfo object. However, some will need to be hardcoded.
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
195 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
196 ## The association between file extensions and coders needs to be done
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
197 ## with a manually coded list (file extensions do not define the image
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
198 ## format and GraphicsMagick will not be fooled by changing the extension).
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
199 ##
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
200 ## We can get the read, write, description and multipage fields from
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
201 ## CoderInfo in C++. We should do the same for alpha (GraphicsMagick
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
202 ## calls it matte) but it's not available from CoderInfo. The only way to
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
203 ## check it is to create a sample image with each coder, then try to read
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
204 ## it back with GraphicsMagick and use the matte method on the Image class.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
205 ## But making such test for each Octave session... meh! While technically
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
206 ## it may be possible that the same coder has different support for alpha
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
207 ## channel in different versions and builds, this doesn't seem to happen.
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
208 ## So we also hardcode those. In the future, maybe the CoderInfo class will
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
209 ## have a matte method like it does for multipage.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
210 ##
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
211 ## Other notes: some formats have more than one coder that do the same. For
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
212 ## example, for jpeg images there is both the JPG and JPEG coders. However,
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
213 ## it seems that when reading images, GraphicsMagick only uses one of them
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
214 ## and that's the one we list (it's the one reported by imfinfo and that we
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
215 ## can use for isa). However, in some cases GraphicsMagick seems to rely
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
216 ## uniquely on the file extension (JBIG and JBG at least. Create an image
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
217 ## with each of those coders, swap their extension and it will report the
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
218 ## other coder). We don't have such cases on the whitelist but if we did, we
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
219 ## would need two entries for such cases.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
220
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
221 ## each row: 1st => Coder, 2nd=> file extensions, 3rd=> alpha
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
222 coders = {"BMP", {"bmp"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
223 "CUR", {"cur"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
224 "GIF", {"gif"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
225 "ICO", {"ico"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
226 "JBG", {"jbg"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
227 "JBIG", {"jbig"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
228 "JP2", {"jp2", "jpx"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
229 "JPEG", {"jpg", "jpeg"}, false; # there is also a JPG coder
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
230 "PBM", {"pbm"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
231 "PCX", {"pcx"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
232 "PGM", {"pgm"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
233 "PNG", {"png"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
234 ## PNM is a family of formats supporting portable bitmaps (PBM),
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
235 ## graymaps (PGM), and pixmaps (PPM). There is no file format
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
236 ## associated with pnm itself. If PNM is used as the output format
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
237 ## specifier, then GraphicsMagick automatically selects the most
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
238 ## appropriate format to represent the image.
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
239 "PNM", {"pnm"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
240 "PPM", {"ppm"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
241 "SUN", {"ras"}, true; # SUN Rasterfile
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
242 "TGA", {"tga", "tpic"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
243 "TIFF", {"tif", "tiff"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
244 "XBM", {"xbm"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
245 "XPM", {"xpm"}, true;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
246 "XWD", {"xwd"}, false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
247 };
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
248
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
249 for fidx = 1: rows(coders)
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
250 formats(fidx).coder = coders{fidx, 1};
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
251 formats(fidx).ext = coders{fidx, 2};
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
252 formats(fidx).alpha = coders{fidx, 3};
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
253 ## default isa is to check if the format returned by imfinfo is the coder
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
254 formats(fidx).isa = @(x) isa_magick (coders{fidx,1}, x);
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
255 endfor
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
256
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
257 ## the default info, read, and write functions
17086
3db796f89695 Rename private core_imfnc functions to follow the __fnc__ convention style.
Carnë Draug <carandraug@octave.org>
parents: 16949
diff changeset
258 [formats.info ] = deal (@__imfinfo__);
3db796f89695 Rename private core_imfnc functions to follow the __fnc__ convention style.
Carnë Draug <carandraug@octave.org>
parents: 16949
diff changeset
259 [formats.read ] = deal (@__imread__);
3db796f89695 Rename private core_imfnc functions to follow the __fnc__ convention style.
Carnë Draug <carandraug@octave.org>
parents: 16949
diff changeset
260 [formats.write] = deal (@__imwrite__);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
261
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
262 ## fills rest of format information by checking with GraphicsMagick
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
263 formats = __magick_formats__ (formats);
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
264
24458
516437d2194d don't allow function parameters (in or out) to be persistent
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
265 rformats = formats;
516437d2194d don't allow function parameters (in or out) to be persistent
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
266
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
267 endfunction
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
268
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
269 function is_valid_format (format)
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21634
diff changeset
270 ## the minimal list of fields required in the structure. We don't
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
271 ## require multipage because it doesn't exist in matlab
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
272 min_fields = {"ext", "read", "isa", "write", "info", "alpha", "description"};
17386
6dbc866379e2 Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents: 17351
diff changeset
273 fields_mask = isfield (format, min_fields);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
274 if (! all (fields_mask))
27216
823b4bcf79fc unless necessary for formatting or code, use ' instead of `
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
275 error ("imformats: structure has missing field '%s'.", min_fields(! fields_mask){1});
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
276 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
277
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
278 endfunction
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
279
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
280 function match = find_ext_idx (formats, ext)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
281 ## FIXME: what should we do if there's more than one hit?
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
282 ## Should this function prevent the addition of
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
283 ## duplicated extensions?
18292
4718af222d9d image/imformats.m: be case insensitive about file extension.
Carnë Draug <carandraug@octave.org>
parents: 17580
diff changeset
284 match = cellfun (@(x) any (strcmpi (x, ext)), {formats.ext});
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
285 endfunction
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
286
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
287 function bool = isa_magick (coder, filename)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
288
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
289 bool = false;
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
290 try
17351
80bf005cdf8e New function __magick_ping__ to speed reading of images.
Carnë Draug <carandraug@octave.org>
parents: 17338
diff changeset
291 info = __magick_ping__ (filename, 1);
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
292 bool = strcmp (coder, info.Format);
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
293 end_try_catch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
294
16901
861516dcad19 New function imformats.
Carnë Draug <carandraug@octave.org>
parents:
diff changeset
295 endfunction
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
296
20170
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
297 function pretty_print_formats (formats)
20169
cf96961effdb imformats.m: implement pretty print when nargout is zero (bug #44119)
Hartmut Gimpel <hg_code@gmx.de>
parents: 19697
diff changeset
298 ## define header names (none should be shorter than 3 characters)
20170
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
299 headers = {"Extension", "isa", "Info", "Read", "Write", "Alpha", "Description"};
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
300 cols_length = cellfun (@numel, headers);
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
301
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
302 ## Adjust the maximal length of the extensions column
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
303 extensions = cellfun (@strjoin, {formats.ext}, {", "},
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
304 "UniformOutput", false);
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
305 cols_length(1) = max (max (cellfun (@numel, extensions)), cols_length(1));
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
306 headers{1} = postpad (headers{1}, cols_length(1), " ");
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
307
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
308 ## Print the headers
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
309 disp (strjoin (headers, " | "));
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
310 under_headers = cellfun (@(x) repmat ("-", 1, numel (x)), headers,
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
311 "UniformOutput", false);
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
312 disp (strjoin (under_headers, "-+-"));
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
313
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
314 template = strjoin (arrayfun (@(x) sprintf ("%%-%is", x), cols_length,
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
315 "UniformOutput", false), " | ");
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
316
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
317 ## Print the function handle for this things won't be a pretty table. So
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
318 ## instead we replace them with "yes" or "no", based on the support it has.
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
319 yes_no_cols = cat (2, {formats.isa}(:), {formats.info}(:), {formats.read}(:),
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
320 {formats.write}(:), {formats.alpha}(:));
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
321 empty = cellfun (@isempty, yes_no_cols);
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
322 yes_no_cols(empty) = "no";
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
323 yes_no_cols(! empty) = "yes";
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
324
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
325 descriptions = {formats.description};
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
326 table = cat (2, extensions(:), yes_no_cols, descriptions(:));
21634
96518f623c91 Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents: 21633
diff changeset
327 printf ([template "\n"], table'{:});
20170
c0f64bc26eee imformats.m: rewrite pretty print of format table.
Carnë Draug <carandraug@octave.org>
parents: 20169
diff changeset
328
20169
cf96961effdb imformats.m: implement pretty print when nargout is zero (bug #44119)
Hartmut Gimpel <hg_code@gmx.de>
parents: 19697
diff changeset
329 endfunction
cf96961effdb imformats.m: implement pretty print when nargout is zero (bug #44119)
Hartmut Gimpel <hg_code@gmx.de>
parents: 19697
diff changeset
330
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21751
diff changeset
331
21489
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
332 ## This must work, even without support for image IO
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
333 %!test
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
334 %! formats = imformats ();
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21489
diff changeset
335 %! assert (isstruct (formats));
21489
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
336 %!
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
337 %! min_fields = {"ext", "read", "isa", "write", "info", "alpha", "description"};
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21489
diff changeset
338 %! assert (all (ismember (min_fields, fieldnames (formats))));
21489
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
339 %!
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
340 %! if (__have_feature__ ("MAGICK"))
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21489
diff changeset
341 %! assert (numel (formats) > 0);
21489
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
342 %! else
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21489
diff changeset
343 %! assert (numel (formats), 0);
21489
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
344 %! endif
ea81c2fdd568 imformats: return empty instead of error if there's no support for image IO.
Carnë Draug <carandraug@octave.org>
parents: 20852
diff changeset
345
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
346 ## When imread or imfinfo are called, the file must exist or the
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
347 ## function defined by imformats will never be called. Because
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
348 ## of this, we must create a file for the tests to work.
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
349
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
350 ## changing the function that does the reading
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
351 %!testif HAVE_MAGICK
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18298
diff changeset
352 %! fname = [tempname() ".jpg"];
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
353 %! def_fmt = imformats ();
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
354 %! fid = fopen (fname, "w");
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
355 %! unwind_protect
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
356 %! fmt = imformats ("jpg");
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
357 %! fmt.read = @numel;
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
358 %! imformats ("update", "jpg", fmt);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
359 %! assert (imread (fname), numel (fname));
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
360 %! unwind_protect_cleanup
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
361 %! fclose (fid);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
362 %! unlink (fname);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
363 %! imformats (def_fmt);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
364 %! end_unwind_protect
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
365
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
366 ## adding a new format
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
367 %!testif HAVE_MAGICK
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18298
diff changeset
368 %! fname = [tempname() ".new_fmt"];
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
369 %! def_fmt = imformats ();
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
370 %! fid = fopen (fname, "w");
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
371 %! unwind_protect
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
372 %! fmt = imformats ("jpg"); # take jpg as template
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
373 %! fmt.ext = "new_fmt";
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
374 %! fmt.read = @() true ();
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
375 %! imformats ("add", fmt);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
376 %! assert (imread (fname), true);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
377 %! unwind_protect_cleanup
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
378 %! fclose (fid);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
379 %! unlink (fname);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
380 %! imformats (def_fmt);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
381 %! end_unwind_protect
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
382
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
383 ## adding multiple formats at the same time
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
384 %!testif HAVE_MAGICK
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18298
diff changeset
385 %! fname1 = [tempname() ".new_fmt1"];
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
386 %! fid1 = fopen (fname1, "w");
19278
6ca096827123 Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents: 18298
diff changeset
387 %! fname2 = [tempname() ".new_fmt2"];
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
388 %! fid2 = fopen (fname2, "w");
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
389 %! def_fmt = imformats ();
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
390 %! unwind_protect
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
391 %! fmt = imformats ("jpg"); # take jpg as template
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
392 %! fmt.ext = "new_fmt1";
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
393 %! fmt.read = @() true();
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
394 %! fmt(2) = fmt(1);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
395 %! fmt(2).ext = "new_fmt2";
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
396 %! imformats ("add", fmt);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
397 %! assert (imread (fname1), true);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
398 %! assert (imread (fname2), true);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
399 %! unwind_protect_cleanup
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
400 %! fclose (fid1);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
401 %! fclose (fid2);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
402 %! unlink (fname1);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
403 %! unlink (fname2);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
404 %! imformats (def_fmt);
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
405 %! end_unwind_protect
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
406
18298
15db54c4a572 Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
Carnë Draug <carandraug@octave.org>
parents: 18297
diff changeset
407 ## changing format and resetting back to default
16949
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
408 %!testif HAVE_MAGICK
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
409 %! ori_fmt = mod_fmt = imformats ("jpg");
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
410 %! mod_fmt.description = "Another description";
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
411 %! imformats ("update", "jpg", mod_fmt);
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
412 %! new_fmt = imformats ("jpg");
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
413 %! assert (new_fmt.description, mod_fmt.description);
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
414 %! imformats ("factory");
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
415 %! new_fmt = imformats ("jpg");
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
416 %! assert (new_fmt.description, ori_fmt.description);
1eb5e5f0ee13 imformats.m: add tests and fix bug when adding new formats.
Carnë Draug <carandraug@octave.org>
parents: 16922
diff changeset
417
18297
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
418 ## updating to an invalid format should cause an error
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
419 %!testif HAVE_MAGICK
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
420 %! fmt = imformats ("jpg");
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
421 %! fmt = rmfield (fmt, "read");
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
422 %! error_thrown = false;
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
423 %! try
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
424 %! imformats ("update", "jpg", fmt);
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
425 %! catch
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
426 %! error_thrown = true;
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
427 %! end_try_catch
1589b2fc74ae imformats.m: add test for updating a format with invalid struct.
Carnë Draug <carandraug@octave.org>
parents: 18292
diff changeset
428 %! assert (error_thrown, true);