Mercurial > hg > octave-nkf
diff scripts/image/imwrite.m @ 16988:54b75bed4bc7
imwrite: implement WriteMode option.
* imwrite.m: document the new option WriteMode and possibility to write
multipage images by passing a 4 dimensional matrix.
* private/core_imwrite.m: perform input check for the quality option and
the new writemode. Set defaults here and not on __magick_write__().
Give warning about the fact that writing of indexed images is not
properly implemented. Change calling to ind2rgb() since it has been
there and we no longer need workaround. Remove the different calls
to __magick_read__() since we now have a single way to do it. Remove
conversion of image types since we want to save what was actually given
to us.
* __magick_read__.cc (read_file): split from __magick_read__() into a
separate function so it can be used by __magick_write__() when appending
images to an existing file.
(jpg_settings): remove function. It only checks for the quality option,
which is now done by core_imwrite(). Plus, other formats support this
option so it was moved into __magick_write__(). We should have functions
for each option rather than per file format.
(encode_map): comment whole function since it is never used and is
unfinished work to implement writing of actual indexed images.
(write_file): new function from part of previous write_image(). It is
now the other side of read_file().
(write_image): remove function. Moved into __magick_write__(), the only
function calling it. The part of writing moved into write_file().
(__magick_write__): removed most of input check which should be done by
imwrite(). Removed all extra usage types. Options must be passed on a
non-optional struct. Implement the Append option.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Tue, 16 Jul 2013 17:29:45 +0100 |
parents | ee2166121a28 |
children | 3db796f89695 |
line wrap: on
line diff
--- a/scripts/image/imwrite.m +++ b/scripts/image/imwrite.m @@ -20,23 +20,43 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} imwrite (@var{img}, @var{filename}) ## @deftypefnx {Function File} {} imwrite (@var{img}, @var{filename}, @var{ext}) -## @deftypefnx {Function File} {} imwrite (@var{img}, @var{filename}, @var{ext}, @var{p1}, @var{v1}, @dots{}) -## @deftypefnx {Function File} {} imwrite (@var{img}, @var{map}, @var{filename}, @dots{}) +## @deftypefnx {Function File} {} imwrite (@var{img}, @var{map}, @var{filename}) +## @deftypefnx {Function File} {} imwrite (@dots{}, @var{param1}, @var{val1}, @dots{}) ## Write images in various file formats. ## +## The image @var{img} can be a binary, grayscale, RGB, or multidimensional +## image. The size and class of @var{img} should be the same as what should +## be expected when reading it with @code{imread}: the 3rd and 4th dimensions +## reserved for colorspace, and multiple pages respectively. If it's an +## indexed image, the colormap @var{map} must also be specified. +## ## If @var{ext} is not supplied, the file extension of @var{filename} is used ## to determine the format. The actual supported formats are dependent on ## options made during the build of Octave. Use @code{imformats} to check ## the support of the different image formats. ## -## The parameter-value pairs (@var{p1}, @var{v1}, @dots{}) are optional. -## Currently the following options are supported for @t{JPEG} images: +## Depending on the file format, it is possible to configure the writing +## of images with @var{param}, @var{val} pairs. The following options +## are supported: ## ## @table @samp ## @item Quality ## Set the quality of the compression. The value should be an ## integer between 0 and 100, with larger values indicating higher visual -## quality and lower compression. +## quality and lower compression. Defaults to 75. +## +## @item WriteMode +## Some file formats, such as TIFF and GIF, are able to store multiple +## images in a single file. This option specifies if @var{img} should be +## appended to the file (if it exists) or if a new file should be created +## for it (possibly overwriting an existing file). The value should be +## the string "Overwrite" (default), or "Append". +## +## Despite this option, the most efficient method of writing a multipage +## image is to pass a 4 dimensional @var{img} to @code{imwrite}, the +## same matrix that could be expected when using @code{imread} with the +## option "Index" set to "all". +## ## @end table ## ## @seealso{imread, imfinfo, imformats}