26 #if defined (HAVE_CONFIG_H) 40 #if defined (HAVE_MAGICK) 77 bool indexed = (img.classType () == Magick::PseudoClass);
87 else if (fmt ==
"PNG")
97 const_cast<Magick::Image&
> (img).attribute (
"PNG:IHDR.color-type-orig");
98 if (! color_type.empty () && color_type !=
"3")
125 && img.channelDepth (Magick::RedChannel) == 1
126 && img.channelDepth (Magick::GreenChannel) == 1
127 && img.channelDepth (Magick::BlueChannel) == 1
128 && img.channelDepth (Magick::CyanChannel) == 1
129 && img.channelDepth (Magick::MagentaChannel) == 1
130 && img.channelDepth (Magick::YellowChannel) == 1
131 && img.channelDepth (Magick::BlackChannel) == 1
132 && img.channelDepth (Magick::OpacityChannel) == 1
133 && img.channelDepth (Magick::GrayChannel) == 1)
155 error (
"__magick_read__: unknown datatype for Region option");
177 m_row_start = rows.
base () - 1;
178 m_col_start = cols.
base () - 1;
179 m_row_end = rows.
max () - 1;
180 m_col_end = cols.
max () - 1;
182 m_row_cache = m_row_end - m_row_start + 1;
183 m_col_cache = m_col_end - m_col_start + 1;
185 m_row_shift = m_col_cache * rows.
inc ();
186 m_col_shift = m_col_cache * (m_row_cache + rows.
inc () - 1) - cols.
inc ();
188 m_row_out = rows.
numel ();
189 m_col_out = cols.
numel ();
256 const Magick::ColorRGB
c = img.colorMap (
i);
257 cmap(
i,0) =
c.red ();
258 cmap(
i,1) =
c.green ();
259 cmap(
i,2) =
c.blue ();
260 amap(
i) =
c.alpha ();
268 template <
typename T>
275 typedef typename T::element_type P;
290 T img = T (
dim_vector (nRows, nCols, 1, nFrames));
291 P *img_fvec = img.fortran_vec ();
308 imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
309 col_cache, row_cache);
311 const Magick::IndexPacket *pix
312 = imvec[frameidx(
frame)].getConstIndexes ();
318 img_fvec[idx++] =
static_cast<P
> (*pix);
335 read_maps (const_cast<Magick::Image&> (imvec[frameidx(def_elem)]));
340 if (imvec[def_elem].matte () &&
nargout >= 3)
342 const Matrix amap = maps(1).matrix_value ();
352 alpha_fvec[pix] = 1 - amap_fvec[static_cast<int> (img_fvec[3])];
365 template <
typename T>
372 typedef typename T::element_type P;
414 if (imvec[def_elem].depth () == 32)
417 divisor = MaxRGB / ((uint64_t (1) << imvec[def_elem].depth ()) - 1);
426 Magick::ImageType
type = imvec[def_elem].type ();
427 if (
type == Magick::BilevelType && imvec[def_elem].matte ())
428 type = Magick::GrayscaleMatteType;
437 if (imvec[0].magick () ==
"PNG")
448 = imvec[0].attribute (
"PNG:IHDR.color-type-orig");
451 type = Magick::GrayscaleType;
452 else if (type_str ==
"2")
453 type = Magick::TrueColorType;
454 else if (type_str ==
"6")
455 type = Magick::TrueColorMatteType;
456 else if (type_str ==
"4")
457 type = Magick::GrayscaleMatteType;
463 if (imvec[0].matte ())
465 if (
type == Magick::GrayscaleType)
466 type = Magick::GrayscaleMatteType;
467 else if (
type == Magick::TrueColorType)
468 type = Magick::TrueColorMatteType;
478 case Magick::GrayscaleMatteType:
479 type = Magick::GrayscaleType;
482 case Magick::PaletteMatteType:
483 type = Magick::PaletteType;
486 case Magick::TrueColorMatteType:
487 type = Magick::TrueColorType;
490 case Magick::ColorSeparationMatteType:
491 type = Magick::ColorSeparationType;
504 case Magick::BilevelType:
505 case Magick::GrayscaleType:
507 img = T (
dim_vector (nRows, nCols, 1, nFrames));
508 P *img_fvec = img.fortran_vec ();
515 const Magick::PixelPacket *pix
516 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
517 col_cache, row_cache);
523 img_fvec[idx++] = pix->red / divisor;
532 case Magick::GrayscaleMatteType:
534 img = T (
dim_vector (nRows, nCols, 1, nFrames));
535 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
536 P *img_fvec = img.fortran_vec ();
537 P *a_fvec = alpha.fortran_vec ();
544 const Magick::PixelPacket *pix
545 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
546 col_cache, row_cache);
552 img_fvec[idx] = pix->red / divisor;
553 a_fvec[idx] = (MaxRGB - pix->opacity) / divisor;
564 case Magick::PaletteType:
565 case Magick::TrueColorType:
567 img = T (
dim_vector (nRows, nCols, 3, nFrames));
568 P *img_fvec = img.fortran_vec ();
575 const Magick::PixelPacket *pix
576 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
577 col_cache, row_cache);
581 P *gbuf = img_fvec + color_stride;
582 P *bbuf = img_fvec + color_stride * 2;
588 rbuf[idx] = pix->red / divisor;
589 gbuf[idx] = pix->green / divisor;
590 bbuf[idx] = pix->blue / divisor;
596 img_fvec += frame_stride;
601 case Magick::PaletteMatteType:
602 case Magick::TrueColorMatteType:
604 img = T (
dim_vector (nRows, nCols, 3, nFrames));
605 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
606 P *img_fvec = img.fortran_vec ();
607 P *a_fvec = alpha.fortran_vec ();
618 const Magick::PixelPacket *pix
619 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
620 col_cache, row_cache);
624 P *gbuf = img_fvec + color_stride;
625 P *bbuf = img_fvec + color_stride * 2;
631 rbuf[idx] = pix->red / divisor;
632 gbuf[idx] = pix->green / divisor;
633 bbuf[idx] = pix->blue / divisor;
634 a_fvec[a_idx++] = (MaxRGB - pix->opacity) / divisor;
640 img_fvec += frame_stride;
646 case Magick::ColorSeparationType:
648 img = T (
dim_vector (nRows, nCols, 4, nFrames));
649 P *img_fvec = img.fortran_vec ();
656 const Magick::PixelPacket *pix
657 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
658 col_cache, row_cache);
662 P *mbuf = img_fvec + color_stride;
663 P *ybuf = img_fvec + color_stride * 2;
664 P *kbuf = img_fvec + color_stride * 3;
670 cbuf[idx] = pix->red / divisor;
671 mbuf[idx] = pix->green / divisor;
672 ybuf[idx] = pix->blue / divisor;
673 kbuf[idx] = pix->opacity / divisor;
679 img_fvec += frame_stride;
685 case Magick::ColorSeparationMatteType:
687 img = T (
dim_vector (nRows, nCols, 4, nFrames));
688 T alpha (
dim_vector (nRows, nCols, 1, nFrames));
689 P *img_fvec = img.fortran_vec ();
690 P *a_fvec = alpha.fortran_vec ();
701 const Magick::PixelPacket *pix
702 = imvec[frameidx(
frame)].getConstPixels (col_start, row_start,
703 col_cache, row_cache);
706 const Magick::IndexPacket *apix
707 = imvec[frameidx(
frame)].getConstIndexes ();
711 P *mbuf = img_fvec + color_stride;
712 P *ybuf = img_fvec + color_stride * 2;
713 P *kbuf = img_fvec + color_stride * 3;
719 cbuf[idx] = pix->red / divisor;
720 mbuf[idx] = pix->green / divisor;
721 ybuf[idx] = pix->blue / divisor;
722 kbuf[idx] = pix->opacity / divisor;
723 a_fvec[a_idx++] = (MaxRGB - *apix) / divisor;
729 img_fvec += frame_stride;
736 error (
"__magick_read__: unknown Magick++ image type");
750 Magick::readImages (&imvec,
filename);
752 catch (Magick::Warning&
w)
754 warning (
"Magick++ warning: %s",
w.what ());
756 catch (Magick::Exception&
e)
758 error (
"Magick++ exception: %s",
e.what ());
771 const char *static_locale = setlocale (LC_ALL,
nullptr);
776 Magick::InitializeMagick (program_name.c_str ());
779 setlocale (LC_ALL, locale.c_str ());
800 if (QuantumDepth < 16)
802 "your version of %s limits images to %d bits per pixel\n",
803 MagickPackageName, QuantumDepth);
822 #if defined (HAVE_MAGICK) 824 if (args.length () != 2 || ! args(0).is_string ())
830 = args(1).xscalar_map_value (
"__magick_read__: OPTIONS must be a struct");
834 std::vector<Magick::Image> imvec;
835 read_file (args(0).string_value (), imvec);
849 frameidx = indexes.
xint_vector_value (
"__magick_read__: invalid value for Index/Frame");
857 if (frameidx(
i) < 0 || frameidx(
i) > nFrames - 1)
862 error (
"imread: index/frames specified are outside the number of images");
872 const unsigned int nRows = imvec[frameidx(0)].rows ();
873 const unsigned int nCols = imvec[frameidx(0)].columns ();
877 if (nRows != imvec[frameidx(
frame)].rows ()
878 || nCols != imvec[frameidx(
frame)].columns ())
880 error (
"imread: all frames must have the same size but frame %i is different",
890 output = read_indexed_images<boolNDArray> (imvec, frameidx,
893 output = read_indexed_images<uint8NDArray> (imvec, frameidx,
895 else if (depth <= 16)
896 output = read_indexed_images<uint16NDArray> (imvec, frameidx,
899 error (
"imread: indexed images with depths greater than 16-bit are not supported");
905 output = read_images<boolNDArray> (imvec, frameidx,
nargout,
options);
907 output = read_images<uint8NDArray> (imvec, frameidx,
nargout,
options);
908 else if (depth <= 16)
909 output = read_images<uint16NDArray> (imvec, frameidx,
nargout,
options);
910 else if (depth <= 32)
911 output = read_images<FloatNDArray> (imvec, frameidx,
nargout,
options);
913 error (
"imread: reading of images with %i-bit depth is not supported",
921 octave_unused_parameter (args);
922 octave_unused_parameter (
nargout);
934 #if defined (HAVE_MAGICK) 936 template <
typename T>
938 img_float2uint (
const T& img)
940 typedef typename T::element_type P;
944 const P *img_fvec = img.fortran_vec ();
949 out_fvec[idx] = img_fvec[idx] *
max;
956 template <
typename T>
958 bitdepth_from_class ()
960 typedef typename T::element_type P;
962 sizeof (P) * std::numeric_limits<unsigned char>::digits;
969 const Magick::ImageType&
type,
970 const Magick::ClassType& klass)
972 Magick::Image img (Magick::Geometry (nCols, nRows),
"black");
976 img.classType (klass);
980 img.depth (bitdepth);
983 case Magick::GrayscaleMatteType:
984 case Magick::TrueColorMatteType:
985 case Magick::ColorSeparationMatteType:
986 case Magick::PaletteMatteType:
997 template <
typename T>
999 encode_indexed_images (std::vector<Magick::Image>& imvec,
1003 typedef typename T::element_type P;
1004 const octave_idx_type nFrames = (img.ndims () < 4 ? 1 : img.dims ()(3));
1012 std::vector<Magick::ColorRGB> colormap;
1018 colormap.push_back (Magick::ColorRGB (cmap_fvec[map_idx],
1019 cmap_fvec[map_idx + G_offset],
1020 cmap_fvec[map_idx + B_offset]));
1027 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1028 Magick::PaletteType,
1029 Magick::PseudoClass);
1032 m_img.colorMapSize (cmap_size);
1034 m_img.colorMap (map_idx, colormap[map_idx]);
1045 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1046 Magick::IndexPacket *
ind = m_img.getIndexes ();
1047 const P *img_fvec = img.fortran_vec ();
1055 pix[GM_idx] = m_img.colorMap (
double (*img_fvec));
1059 GM_idx -= nCols * nRows - 1;
1063 m_img.syncPixels ();
1064 imvec.push_back (m_img);
1069 encode_bool_image (std::vector<Magick::Image>& imvec,
const boolNDArray& img)
1076 const Magick::Color white (
"white");
1088 Magick::Image m_img = init_enconde_image (nCols, nRows, 1,
1089 Magick::GrayscaleType,
1090 Magick::DirectClass);
1092 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1098 if (img_fvec[img_idx])
1099 pix[GM_idx] = white;
1104 GM_idx -= nCols * nRows - 1;
1107 m_img.syncPixels ();
1110 m_img.type (Magick::BilevelType);
1111 imvec.push_back (m_img);
1115 template <
typename T>
1117 encode_uint_image (std::vector<Magick::Image>& imvec,
1118 const T& img,
const T& alpha)
1120 typedef typename T::element_type P;
1121 const octave_idx_type channels = (img.ndims () < 3 ? 1 : img.dims ()(2));
1122 const octave_idx_type nFrames = (img.ndims () < 4 ? 1 : img.dims ()(3));
1127 Magick::ImageType
type;
1128 const bool has_alpha = ! alpha.isempty ();
1133 type = Magick::GrayscaleMatteType;
1135 type = Magick::GrayscaleType;
1140 type = Magick::TrueColorMatteType;
1142 type = Magick::TrueColorType;
1147 type = Magick::ColorSeparationMatteType;
1149 type = Magick::ColorSeparationType;
1154 error (
"__magick_write__: wrong size on 3rd dimension");
1164 const double divisor =
static_cast<double>((uint64_t (1) << bitdepth) - 1)
1167 const P *img_fvec = img.fortran_vec ();
1168 const P *a_fvec = alpha.fortran_vec ();
1171 case Magick::GrayscaleType:
1177 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1179 Magick::DirectClass);
1181 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1188 Magick::Color
c (grey, grey, grey);
1193 GM_idx -= nCols * nRows - 1;
1196 m_img.syncPixels ();
1197 imvec.push_back (m_img);
1202 case Magick::GrayscaleMatteType:
1208 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1210 Magick::DirectClass);
1212 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1219 Magick::Color
c (grey, grey, grey,
1226 GM_idx -= nCols * nRows - 1;
1229 m_img.syncPixels ();
1230 imvec.push_back (m_img);
1235 case Magick::TrueColorType:
1244 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1246 Magick::DirectClass);
1248 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1261 GM_idx -= nCols * nRows - 1;
1264 m_img.syncPixels ();
1265 imvec.push_back (m_img);
1266 img_fvec += B_offset;
1271 case Magick::TrueColorMatteType:
1280 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1282 Magick::DirectClass);
1284 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1299 GM_idx -= nCols * nRows - 1;
1302 m_img.syncPixels ();
1303 imvec.push_back (m_img);
1304 img_fvec += B_offset;
1309 case Magick::ColorSeparationType:
1319 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1321 Magick::DirectClass);
1323 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1337 GM_idx -= nCols * nRows - 1;
1340 m_img.syncPixels ();
1341 imvec.push_back (m_img);
1342 img_fvec += K_offset;
1347 case Magick::ColorSeparationMatteType:
1357 Magick::Image m_img = init_enconde_image (nCols, nRows, bitdepth,
1359 Magick::DirectClass);
1361 Magick::PixelPacket *pix = m_img.getPixels (0, 0, nCols, nRows);
1362 Magick::IndexPacket *
ind = m_img.getIndexes ();
1378 GM_idx -= nCols * nRows - 1;
1381 m_img.syncPixels ();
1382 imvec.push_back (m_img);
1383 img_fvec += K_offset;
1389 error (
"__magick_write__: unrecognized Magick::ImageType");
1396 static std::map<octave_idx_type, std::string>
1397 init_disposal_methods ()
1414 static std::map<octave_idx_type, std::string> methods;
1415 if (methods.empty ())
1417 methods[0] =
"doNotSpecify";
1418 methods[1] =
"leaveInPlace";
1419 methods[2] =
"restoreBG";
1420 methods[3] =
"restorePrevious";
1424 static std::map<std::string, octave_idx_type>
1425 init_reverse_disposal_methods ()
1427 static std::map<std::string, octave_idx_type> methods;
1428 if (methods.empty ())
1430 methods[
"donotspecify"] = 0;
1431 methods[
"leaveinplace"] = 1;
1432 methods[
"restorebg"] = 2;
1433 methods[
"restoreprevious"] = 3;
1441 std::vector<Magick::Image>& imvec)
1445 Magick::writeImages (imvec.begin (), imvec.end (), ext +
':' +
filename);
1447 catch (Magick::Warning&
w)
1449 warning (
"Magick++ warning: %s",
w.what ());
1451 catch (Magick::ErrorCoder&
e)
1453 warning (
"Magick++ coder error: %s",
e.what ());
1455 catch (Magick::Exception&
e)
1457 error (
"Magick++ exception: %s",
e.what ());
1463 DEFUN (__magick_write__, args, ,
1474 #if defined (HAVE_MAGICK) 1476 if (args.length () != 5 || ! args(0).is_string () || ! args(1).is_string ())
1485 = args(4).xscalar_map_value (
"__magick_write__: OPTIONS must be a struct");
1488 const Matrix cmap = args(3).xmatrix_value (
"__magick_write__: invalid MAP");
1490 std::vector<Magick::Image> imvec;
1517 clip_img = img_float2uint<FloatNDArray>
1519 clip_alpha = img_float2uint<FloatNDArray>
1524 clip_img = img_float2uint<NDArray> (img.
array_value ());
1525 clip_alpha = img_float2uint<NDArray> (alpha.
array_value ());
1527 encode_uint_image<uint32NDArray> (imvec, clip_img, clip_alpha);
1530 error (
"__magick_write__: image type not supported");
1544 error (
"__magick_write__: indexed image must be uint8, uint16 or float.");
1546 static std::map<std::string, octave_idx_type> disposal_methods
1547 = init_reverse_disposal_methods ();
1553 options.getfield (
"delaytime").column_vector_value ();
1555 options.getfield (
"disposalmethod").cellstr_value ();
1558 imvec[
i].quality (quality);
1559 imvec[
i].animationDelay (delaytime(
i));
1560 imvec[
i].gifDisposeMethod (disposal_methods[disposalmethod(
i)]);
1568 std::vector<Magick::Image> ini_imvec;
1571 if (ini_imvec.size () > 0)
1573 ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ());
1574 ini_imvec.swap (imvec);
1602 imvec[0].animationIterations (
options.getfield (
"loopcount").uint_value ());
1605 =
options.getfield (
"compression").string_value ();
1607 #define COMPRESS_MAGICK_IMAGE_VECTOR(GM_TYPE) \ 1608 for (std::vector<Magick::Image>::size_type i = 0; i < imvec.size (); i++) \ 1609 imvec[i].compressType (GM_TYPE) 1611 if (compression ==
"none")
1613 else if (compression ==
"bzip")
1615 else if (compression ==
"fax3")
1617 else if (compression ==
"fax4")
1619 else if (compression ==
"jpeg")
1621 else if (compression ==
"lzw")
1623 else if (compression ==
"rle")
1625 else if (compression ==
"deflate")
1628 #undef COMPRESS_MAGICK_IMAGE_VECTOR 1636 octave_unused_parameter (args);
1652 DEFUN (__magick_ping__, args, ,
1662 #if defined (HAVE_MAGICK) 1664 if (args.length () < 1 || ! args(0).is_string ())
1672 if (args.length () > 1)
1673 idx = args(1).int_value () -1;
1684 catch (Magick::Warning&
w)
1686 warning (
"Magick++ warning: %s",
w.what ());
1688 catch (Magick::Exception&
e)
1690 error (
"Magick++ exception: %s",
e.what ());
1693 static const char *
fields[] = {
"rows",
"columns",
"format",
nullptr};
1703 octave_unused_parameter (args);
1710 #if defined (HAVE_MAGICK) 1713 magick_to_octave_value (
const Magick::CompressionType& magick)
1717 case Magick::NoCompression:
1719 case Magick::BZipCompression:
1721 case Magick::FaxCompression:
1723 case Magick::Group4Compression:
1725 case Magick::JPEGCompression:
1727 case Magick::LZWCompression:
1729 case Magick::RLECompression:
1733 case Magick::ZipCompression:
1757 magick_to_octave_value (
const Magick::EndianType& magick)
1761 case Magick::LSBEndian:
1763 case Magick::MSBEndian:
1771 magick_to_octave_value (
const Magick::OrientationType& magick)
1776 case Magick::TopLeftOrientation:
1778 case Magick::TopRightOrientation:
1780 case Magick::BottomRightOrientation:
1782 case Magick::BottomLeftOrientation:
1784 case Magick::LeftTopOrientation:
1786 case Magick::RightTopOrientation:
1788 case Magick::RightBottomOrientation:
1790 case Magick::LeftBottomOrientation:
1798 magick_to_octave_value (
const Magick::ResolutionType& magick)
1802 case Magick::PixelsPerInchResolution:
1804 case Magick::PixelsPerCentimeterResolution:
1816 return (!
val.empty () &&
val !=
"unknown");
1823 const std::string attr = img.attribute (
"EXIF:" + key);
1824 if (is_valid_exif (attr))
1833 const std::string attr = img.attribute (
"EXIF:" + key);
1834 if (is_valid_exif (attr))
1840 std::istringstream sstream (attr);
1842 while (std::getline (sstream, sub,
char (
',')))
1844 sscanf (sub.c_str (),
"%f", &
number);
1856 const std::string attr = img.attribute (
"EXIF:" + key);
1857 if (is_valid_exif (attr))
1864 std::istringstream sstream (attr);
1866 while (std::getline (sstream, sub,
','))
1868 sscanf (sub.c_str (),
"%i/%i", &numerator, &denominator);
1878 DEFUN (__magick_finfo__, args, ,
1889 #if defined (HAVE_MAGICK) 1891 if (args.length () < 1 || ! args(0).is_string ())
1898 std::vector<Magick::Image> imvec;
1922 static const char *
fields[] =
1987 error (
"imfinfo: error reading '%s': %s",
filename.c_str (),
1991 const std::string filetime = mtime.strftime (
"%e-%b-%Y %H:%M:%S");
2001 const Magick::Image img = imvec[
frame];
2003 info_frame.setfield (
"Width",
octave_value (img.columns ()));
2004 info_frame.setfield (
"Height",
octave_value (img.rows ()));
2005 info_frame.setfield (
"BitDepth",
2015 color_type =
"indexed";
2017 read_maps (const_cast<Magick::Image&> (img))(0).matrix_value ();
2021 switch (img.type ())
2023 case Magick::BilevelType:
2024 case Magick::GrayscaleType:
2025 case Magick::GrayscaleMatteType:
2026 color_type =
"grayscale";
2029 case Magick::TrueColorType:
2030 case Magick::TrueColorMatteType:
2031 color_type =
"truecolor";
2034 case Magick::PaletteType:
2035 case Magick::PaletteMatteType:
2037 color_type =
"indexed";
2040 case Magick::ColorSeparationType:
2041 case Magick::ColorSeparationMatteType:
2042 color_type =
"CMYK";
2046 color_type =
"undefined";
2049 info_frame.setfield (
"ColorType",
octave_value (color_type));
2058 double *chroma_fvec = chromaticities.fortran_vec ();
2059 img.chromaWhitePoint (&chroma_fvec[0], &chroma_fvec[1]);
2060 img.chromaRedPrimary (&chroma_fvec[2], &chroma_fvec[3]);
2061 img.chromaGreenPrimary (&chroma_fvec[4], &chroma_fvec[5]);
2062 img.chromaBluePrimary (&chroma_fvec[6], &chroma_fvec[7]);
2063 if (chromaticities.nnz () == 0)
2065 info_frame.setfield (
"Chromaticities",
octave_value (chromaticities));
2068 info_frame.setfield (
"Gamma",
octave_value (img.gamma ()));
2069 info_frame.setfield (
"XResolution",
octave_value (img.xResolution ()));
2070 info_frame.setfield (
"YResolution",
octave_value (img.yResolution ()));
2071 info_frame.setfield (
"DelayTime",
octave_value (img.animationDelay ()));
2072 info_frame.setfield (
"LoopCount",
2074 info_frame.setfield (
"Quality",
octave_value (img.quality ()));
2075 info_frame.setfield (
"Comment",
octave_value (img.comment ()));
2077 info_frame.setfield (
"Compression",
2078 magick_to_octave_value (img.compressType ()));
2079 info_frame.setfield (
"Orientation",
2080 magick_to_octave_value (img.orientation ()));
2081 info_frame.setfield (
"ResolutionUnit",
2082 magick_to_octave_value (img.resolutionUnits ()));
2083 info_frame.setfield (
"ByteOrder",
2084 magick_to_octave_value (img.endian ()));
2090 Magick::Image& cimg =
const_cast<Magick::Image&
> (img);
2099 static const char *base_exif_str_fields[] =
2110 static const string_vector base_exif_str (base_exif_str_fields);
2111 static const octave_idx_type n_base_exif_str = base_exif_str.numel ();
2114 info_frame.setfield (base_exif_str[field],
2116 fill_exif (info_frame, cimg, base_exif_str[field]);
2121 if (! cimg.attribute (
"EXIF:ExifVersion").empty ())
2127 static const char *exif_str_fields[] =
2131 "DateTimeDigitized",
2134 "SubSecTimeOriginal",
2135 "SubSecTimeDigitized",
2142 "SpectralSensitivity",
2152 fill_exif (camera, cimg, exif_str[field]);
2155 static const char *exif_int_fields[] =
2160 "PhotographicSensitivity",
2161 "StandardOutputSensitivity",
2162 "RecommendedExposureIndex",
2164 "ISOSpeedLatitudeyyy",
2165 "ISOSpeedLatitudezzz",
2166 "FocalPlaneResolutionUnit",
2167 "FocalLengthIn35mmFilm",
2190 "SubjectDistanceRange",
2196 fill_exif_ints (camera, cimg, exif_int[field]);
2199 static const char *exif_float_fields[] =
2202 "CompressedBitsPerPixel",
2205 "ShutterSpeedValue",
2208 "ExposureBiasValue",
2213 "FocalPlaneXResolution",
2214 "FocalPlaneYResolution",
2218 "LensSpecification",
2224 fill_exif_floats (camera, cimg, exif_float[field]);
2229 if (cimg.attribute (
"EXIF:GPSInfo") !=
"unknown")
2235 static const char *gps_str_fields[] =
2245 "GPSImgDirectionRef",
2247 "GPSDestLatitudeRef",
2248 "GPSDestLongitudeRef",
2249 "GPSDestBearingRef",
2250 "GPSDestDistanceRef",
2257 fill_exif (gps, cimg, gps_str[field]);
2259 static const char *gps_int_fields[] =
2267 fill_exif_ints (gps, cimg, gps_int[field]);
2269 static const char *gps_float_fields[] =
2278 "GPSHPositioningError",
2290 fill_exif_floats (gps, cimg, gps_float[field]);
2294 info_frame.setfield (
"DigitalCamera",
octave_value (camera));
2298 info.fast_elem_insert (
frame, info_frame);
2303 static std::map<octave_idx_type, std::string> disposal_methods
2304 = init_disposal_methods ();
2307 methods[
frame] = disposal_methods[imvec[
frame].gifDisposeMethod ()];
2308 info.setfield (
"DisposalMethod",
Cell (methods));
2311 info.setfield (
"DisposalMethod",
2318 octave_unused_parameter (args);
2330 DEFUN (__magick_formats__, args, ,
2338 if (args.length () != 1 || ! args(0).isstruct ())
2343 #if defined (HAVE_MAGICK) 2355 fmt.
setfield (
"multipage", coder.isMultiFrame () ? true :
false);
2358 if (! coder.isReadable ())
2360 if (! coder.isWritable ())
2364 catch (Magick::Exception&
e)
2379 return ovl (formats);
std::string error(void) const
octave_idx_type rows(void) const
void warning_with_id(const char *id, const char *fmt,...)
scalar structure containing the fields
octave_idx_type m_row_end
OCTAVE_EXPORT octave_value_list column
bool is_uint32_type(void) const
Range range_value(void) const
octave_idx_type m_col_cache
octave_idx_type col_end(void) const
void delete_elements(const idx_vector &i)
octave_idx_type m_row_out
#define COMPRESS_MAGICK_IMAGE_VECTOR(GM_TYPE)
std::string string_value(bool force=false) const
bool islogical(void) const
string_vector fieldnames(void) const
OCTINTERP_API void print_usage(void)
static Range get_region_range(const octave_value ®ion)
identity matrix If supplied two scalar respectively For allows like xample val
Array< int > xint_vector_value(const char *fmt,...) const
for fields that display a single number
static bool is_indexed(const Magick::Image &img)
octave_scalar_map checkelem(octave_idx_type n) const
const T * fortran_vec(void) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
octave_idx_type col_start(void) const
static void read_file(const std::string &filename, std::vector< Magick::Image > &imvec)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
void setfield(const std::string &key, const octave_value &val)
octave_idx_type row_out(void) const
octave_idx_type columns(void) const
static void maybe_initialize_magick(void)
octave_idx_type row_cache(void) const
octave_idx_type col_shift(void) const
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
FloatNDArray float_array_value(bool frc_str_conv=false) const
cell array If invoked with two or more scalar integer or a vector of integer values
uint32NDArray uint32_array_value(void) const
static octave_value_list read_indexed_images(const std::vector< Magick::Image > &imvec, const Array< octave_idx_type > &frameidx, const octave_idx_type &nargout, const octave_scalar_map &options)
octave_idx_type m_col_out
octave_idx_type m_col_start
octave_idx_type m_col_shift
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
octave_idx_type row_shift(void) const
octave_idx_type row_end(void) const
std::complex< double > w(std::complex< double > z, double relerr=0)
bool is_single_type(void) const
double scalar_value(bool frc_str_conv=false) const
octave_idx_type col_cache(void) const
bool fast_elem_insert(octave_idx_type n, const octave_scalar_map &rhs)
octave_idx_type numel(void) const
void resize(const dim_vector &dv, const T &rfv)
Resizing (with fill).
static octave_int< T > max(void)
octave_value getfield(const std::string &key) const
octave_idx_type m_col_end
octave_idx_type numel(void) const
static octave_value_list read_maps(Magick::Image &img)
octave_value_list read_images(std::vector< Magick::Image > &imvec, const Array< octave_idx_type > &frameidx, const octave_idx_type &nargout, const octave_scalar_map &options)
void setfield(const std::string &key, const Cell &val)
octave_idx_type m_row_shift
void warning(const char *fmt,...)
octave::unwind_protect frame
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
charNDArray max(char d, const charNDArray &m)
boolNDArray bool_array_value(bool warn=false) const
T::size_type numel(const T &str)
static octave_idx_type get_depth(Magick::Image &img)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
image_region(const octave_scalar_map &options)
uint16NDArray uint16_array_value(void) const
octave_idx_type m_row_cache
OCTAVE_EXPORT octave_value_list only variables visible in the local scope are displayed The following are valid options
Cell cell_value(void) const
octave::sys::file_stat fs(filename)
bool is_string(void) const
static std::string get_program_invocation_name(void)
octave_idx_type row_start(void) const
bool is_range(void) const
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type col_out(void) const
Vector representing the dimensions (size) of an Array.
octave_idx_type m_row_start
bool is_uint8_type(void) const
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
nd group nd example For each display the value
sys::time mtime(void) const
bool is_scalar_type(void) const
NDArray array_value(bool frc_str_conv=false) const
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
uint8NDArray uint8_array_value(void) const
bool is_uint16_type(void) const